Lazy instantiation problem

I would like to instantiate collections only when they are needed. It
works fine for non transactional instances but fails when my instance is
transactional with following error:
To perform writes on persistent data outside of a transaction,
the "nontransactionalWrite" property must be set on the
PersistenceManagerFactory or Transaction.
Collection getChildNodesCollection() {
if (childNodes == null) {
childNodes = new ArrayList();
return childNodes;
I guess it is to be expected as JDO have to enhance all assignments to
childNodes collection but is there any way to avoid it. If not I will
have to go back to constructor based initialization which is a waste of
resources because when JDO creates an instance it will replace all
collection I create with its own

Hi,
Sorry, this is not an answer for your question.
I'm a beginner on Kodo, and I wonder how did you do the "lazy instantiation"
of
members of a collection. Can you specify any documents written about it?
Thank you,
Tomohiro Koike
""Roytman, Alex"" <[email protected]> wrote in message
news:[email protected]..
I would like to instantiate collections only when they are needed. It
works fine for non transactional instances but fails when my instance is
transactional with following error:
To perform writes on persistent data outside of a transaction,
the "nontransactionalWrite" property must be set on the
PersistenceManagerFactory or Transaction.
Collection getChildNodesCollection() {
if (childNodes == null) {
childNodes = new ArrayList();
return childNodes;
I guess it is to be expected as JDO have to enhance all assignments to
childNodes collection but is there any way to avoid it. If not I will
have to go back to constructor based initialization which is a waste of
resources because when JDO creates an instance it will replace all
collection I create with its own

Similar Messages

  • Lazy instantiation of AM's data model.

    Hi,
    is there a way to force lazy instantiation of an AM's datamodel. Currently we do it manually by removing the data model content and finding/creating the components as needed.
    This is quite distressing because we now have to keep track of instance names for VO's/VL/embedded AM's manually.
    Any ideas??

    In 9.0.3.4, 9.0.4.0, and 10g, BC4J introduced capability by which an
    ApplicationModule's components are lazily loaded.
    For example, suppose we have an AM with 5 VOs and 3 nested AMs in it
    (as defined in the AM wizard's data model panel in the IDE). When
    the load-components-lazily flag is turned off (which is the default),
    when the AM is created, all 5 VOs and 3 nested AMs inside the AM are
    created.
    If this flag is turned on, then the AM is created without any of its
    components. If you make a call to find these components, e.g.,
    findViewObject, findApplicationModule, the component is instantiated.
    You can turn on load-components-lazily by using a configuration
    property
    jbo.load.components.lazily=true
    You can use the -D JVM flag to set this property as in:
    java -Djbo.load.components.lazily=true ...
    << Things to Note about This Feature >>
    1. If you want this turned on a specif AM definition, you need to
    edit the AM def's XML file. Add an XML attribute
    LoadComponentsLazily="true"
    In the current versions, there is no wizard support for this.
    The next release will add this.
    2. If you call AM interface methods like getViewObjectNames(),
    getApplicationModuleNames(), they return a list of instantiated
    components. I.e., they do not include names of yet-to-be created
    instances.
    3. Even if a component of a specific name has not yet been created,
    if you try to create a new component through runtime API with the
    same name (e.g., createViewObject), you will get a
    NameClashException. I.e., the fact that you have not yet created a
    component doesn't mean that you can use that name.
    4. Another way you can cause components to be created lazily is by
    generating Java file for the AM impl class and then overridding
    public boolean isLoadComponentsLazily()
    return truen;
    5. If load-components-lazily is turned on and if you load a VO
    which is a detail in a data model ViewLink (within an AM), you
    may not see master-detail coordination. You need to load
    (using findViewLink/findViewObject) the VL and master VO first.
    In the next release, the VL and master VO will be loaded
    automatically. For now, you need to manage this manually.

  • Factory Instantiation Problem when publishing WSDL in Service Registry

    I have installed SOA Suite 10.1.3.1 and OSR 10.1.3. and am trying to publish a WSDL for a new business created as admin. This causes an UDDI error, though:
    "Invalid WSDL location! WSDLException: faultCode=CONFIGURATION_ERROR: Problem instantiating factory implementation.: oracle.j2ee.ws.wsdl.factory.WSDLFactoryImpl."
    I checked the jars in {oracle.home}/j2ee and couldn't find WSDLFactoryImpl in any of these. It is contained in orawsdl.jar under jdeveloper and bpel, though.
    Anyone seeing the same problem or are you guys able to use the OSR and publish services ? Hints on how to patch the OSR classpath ? (I am running it as standalone within OC4J).
    cheers,
    Diego

    yes, I do have one tip:
    ..don't install in the "home" instance. Well, to be more precise, don't install in the same instance as your BPEL PM and ESB - which by default is the "home" instance.
    You have to create a new instance (e.g. "registry") for your OSR, see "Integrating Oracle BPEL Process Manager with the Oracle Application Server Service Registry", page 2-32, step 6 in the "Oracle BPEL Process Manager Administrator's Guide".
    Maybe also have a read in
    Re: Anyone successfully installed SOA [Advanced] & Service Registry 10.1.3.1 ?
    good luck :-)
    Message was edited by:
    Diego Tognola

  • Instantiation problem

    Hi !
    To clarify my problem, I have trimmed down the 4 files (here included) to keep just the essential.
    When I try to compile the project, I have a �cannot resolve symbol� message for the drawingPanel and the currentObject objects referenced in the ToolbarPanel class.
    The compiler does not seem to see these objects although they should be already instantiated at this point. All files are in the same directory so the classes should be seen without import statements.
    I had the same problem a while ago and I solved it by using static members or inner classes. But here I cant do that (and it does not make sens to do so).
    I must be missing something about how files relate to each other. I thought that dividing a project into custom Panel related files was a good idea �
    Any clue someone ? Thanks !
    JF
    import java.awt.*;
    import javax.swing.*;
    public class MainWindow extends JFrame {
         public DrawingPanel drawingPanel;
         public ToolbarPanel toolbarPanel;
         public static void main( String args[] )
              MainWindow mainWindow = new MainWindow();
              mainWindow.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
         public MainWindow()
              super( "Testing application" );
              Container mainPanel = getContentPane();
              mainPanel.setLayout( new BorderLayout() );
              //     custom Jpanel
              drawingPanel = new DrawingPanel();
              mainPanel.add( drawingPanel, BorderLayout.CENTER );
              //     custom Jpanel
              toolbarPanel = new ToolbarPanel();                         
              mainPanel.add( toolbarPanel, BorderLayout.NORTH );
              setSize( 800,570 );
              setVisible( true );
    }// class MainWindow*******************************************************************************
    import javax.swing.*;
    public class DrawingPanel extends JPanel {
         public MyObject currentObject;
         public int newVariable;
         public DrawingPanel()
              newVariable = 31;     // Default value
              createNewObject();
         public void createNewObject()
              currentObject = new MyObject( newVariable );
    }// class DrawingPanel*******************************************************************************
    import javax.swing.*;
    import java.awt.event.*;
    public class ToolbarPanel extends JPanel implements ActionListener {
         private JButton addButton;
         public ToolbarPanel()
              addButton = new JButton( "  Add  " );
              add( addButton );
              addButton.addActionListener(this);
         public void actionPerformed( ActionEvent ae )
              if (ae.getSource() == addButton)
                   drawingPanel.newVariable = currentObject.variable ++;
                   drawingPanel.createNewObject();
    }// class ToolbarPanel*******************************************************************************
    public class MyObject {
         public int variable;
         public MyObject( int variable )
              this.variable = variable;
    }// class MyObject

    but that they don't
    need any instance or class qualification toidentify
    them.In Java 1.5 you can accomplish this.
    Sort of. You're just explicitly mentioning the
    qualifier in one place, but it's not completely gone.So ?
    Java has to know where to look for variables ... it can't just mysteriously find them.
    I don't know if you'll find anything "official" that
    settles it once and for all, but a quick google turned
    up enough to convince me not to call 'em "global
    variables."Well, they may not be global in the way other languages think of them (and like you do; i.e. must be referred to w/o prefix) but they are still "global", so it doesn't really matter, IMO.
    Your sentence would be better off something like: "Java doesn't have c-style global variables.".
    For example, the JLS won't tell you explicitly that
    you can have a variable who's value is 10, but itcan
    be accomplished.That's not really the same thing.You are saying that the JLS should explicitly state something as achievable, and if it doesn't you can't say it exists.
    I say: "Java has variables which are equal to 10".
    You say: "Where in the JLS does it say that?"
    Similarly, I say: "Java has variables which can be global"
    You say: "Where in the JLS ... ?"

  • Fetching lazy attribute problem

    Hi all.
    I have a simple question.
    How can i get an unfetched value of an entity attribute marked in my jpa as
    +@Basic (fetch = FetchType.LAZY)+
    +@Column(name="DEPARTMENT_NAME", nullable = false, length = 30)+
    private String departmentName;
    when i try to use a getter method in a client unit:
    SessionEJB sessionEJB = (SessionEJB)context.lookup("EJBAppEx1-Model-SessionEJB#geo.model.SessionEJB");
    List<Departments> f = (List<Departments>)sessionEJB.getDepartmentsFindAll();
    Departments d10 = f.get(10);
    String name = d10.getDepartmentName();+
    i get the error:
    java.lang.IllegalStateException: Cannot get unfetched attribute [departmentName] from detached object geo.model.Departments@a22e0c.
         at org.eclipse.persistence.internal.queries.EntityFetchGroup.onUnfetchedAttribute(EntityFetchGroup.java:92)
         at org.eclipse.persistence.internal.jpa.EntityManagerImpl.processUnfetchedAttribute(EntityManagerImpl.java:2360)
         at geo.model.Departments._persistence_checkFetched(Departments.java)
         at geo.model.Departments._persistence_get_departmentName(Departments.java)
         at geo.model.Departments.getDepartmentName(Departments.java:65)
         at geo.model.SessionEJBClient.main(SessionEJBClient.java:22)
    Thanks in advance. Alex

    Hi,
    this is a JPA-Provider specific question. From the stacktrace I assume you are using eclipseLink. The exception could have many reasons.
    Checkout this forum: http://www.eclipse.org/forums/index.php?t=thread&frm_id=111

  • Am SDK command line sample AMStoreConnection Instantiation problem

    I am trying to use the Sun One am SDK in an java command line sample but when i try to instantiate the AMStoreConnection Object i get the following error:
    Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.iplanet.am.sdk.AMStoreConnection.<clinit>(AMStoreConnection.java:46)
    at CommandLineSSO.main(CommandLineSSO.java:41)
    Caused by: java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key authError-nullInput
    at java.util.ResourceBundle.getObject(ResourceBundle.java:314)
    at java.util.ResourceBundle.getString(ResourceBundle.java:274)
    at com.iplanet.services.util.I18n.getString(I18n.java:255)
    at com.iplanet.authentication.server.AuthSPrincipal.<init>(AuthSPrincipal.java:66)
    at com.iplanet.authentication.AuthPrincipal.<init>(AuthPrincipal.java:49)
    at com.iplanet.am.sdk.AMSDKUtil.<clinit>(AMSDKUtil.java:222)
    ... 2 more
    i the amSDK debug log the error messages is :
    10/25/2002 10:01:31:078 AM CEST: Thread[main,5,main]
    ERROR: AdminUtils: Initialize admin info
    Got LDAPServiceException code=19
         at com.iplanet.services.ldap.DSConfigMgr.loadServerConfiguration(DSConfigMgr.java:299)
         at com.iplanet.services.ldap.DSConfigMgr.getDSConfigMgr(DSConfigMgr.java:54)
         at com.iplanet.am.util.AdminUtils.<clinit>(AdminUtils.java:37)
         at com.iplanet.am.sdk.AMSDKUtil.<clinit>(AMSDKUtil.java:222)
         at com.iplanet.am.sdk.AMStoreConnection.<clinit>(AMStoreConnection.java:46)
         at CommandLineSSO.main(CommandLineSSO.java:41)
    Here is the java code :
              AMObject amObj;
              AMStoreConnection conn;
              SSOTokenManager manager = SSOTokenManager.getInstance();
              SSOToken token = manager.createSSOToken(args[0]);
                   conn = new AMStoreConnection( token);
    /***************************************************************/

    I am having the same problem as was initially posted in this thread, yet it doesn't seem to be fixed by the suggestion below. I have the SUNWam/lib and SUNWam/locale directories in my classpath, which makes all the right properties files available to the classloader.
    I was able to determine that the problem was just a missing line in the amSDK.properties file "authError-nullInput=Null Values" ... but now I just get a NullPointerException
    [25/Jul/2003:11:33:43] failure (25141): Internal error: Unexpected error condition thrown (unknown exception,no description), stack: java.lang.ExceptionInInitializerError: java.lang.NullPointerException: Null Values
         at com.iplanet.authentication.server.AuthSPrincipal.<init>(AuthSPrincipal.java:66)
         at com.iplanet.authentication.AuthPrincipal.<init>(AuthPrincipal.java:49)
         at com.iplanet.am.sdk.AMSDKUtil.<clinit>(AMSDKUtil.java:222)
         at com.iplanet.am.sdk.AMStoreConnection.<clinit>(AMStoreConnection.java:46)
         at test.TestServlet.service(TestServlet.java:90)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.iplanet.server.http.servlet.NSServletRunner.invokeServletService(NSServletRunner.java:897)
         at com.iplanet.server.http.servlet.NSServletRunner.Service(NSServletRunner.java:464)
    any help would be greatly appreciated. thanks.

  • Lazy fetching problem with TopLink essentials

    [TopLink Warning]: 2008.08.02 08:56:14.656--ServerSession(29131495)--Ignoring LAZY fetch type on element [public byte[] org.mayhem.mail.entity.Message.getRawBytes()] within entity class [class org.mayhem.mail.entity.Message]. All basic mappings default to use EAGER fetching.This is what I get when I start TopLink essesntials based JavaEE server. Why is that ?
    No, no..... I knooow that lazy fetching is not required to be supported by a JPA implementor.
    The question is why ?
    I mean, isnt Toplink the official implementation, and arent all features "supposed" to be implemented?
    How can I address this issue ?
    I dont want to fetch the bytes on each accessed message ...... ;(

    TopLink Essentials does not support this optional feature.
    EclipseLink 1.0 does, (JPA 2.0 reference impl). EclipseLink is basically the full open sourcing of the TopLink product, where as TopLink Essentials only included "Essential" features.
    -- James : [http://www.eclipselink.org]

  • BLOB lazy fetch problem.. SOMEONE HELPS !

    Well... Toplink essentials ignores the lazy fetch flag from my entity class. Why is that ?
    Will toplink (non-essentials) ignore it ?
    How can I deal with this issue ?

    lazy on Basic, (actually in general) is an option part of the JPA specification (a hint actually), so TopLink Essentials did not support lazy on Basic (only on relationships).
    EclipseLink 1.0 does support this (as long as you use the weaving agent). It also supports fetch groups beyond the JPA specification.
    A solution without lazy is to move the LOB into another object and define a lazy 1-1 to this object. This is normally a good idea with large LOBs in general, even with lazy support.
    -- James : http://www.eclipselink.org

  • Performance problem with synchronized singleton

    I'm using the singleton pattern to cache incoming JMS Message data from a 3rd party. I'm seeing terrible performance though, and I think it's because I've misunderstood something.
    My singleton class stores incoming JMS messages in a HashMap, so that successive messages can be checked to see if they are a new piece of data, or an update to an earlier one.
    I followed the traditional examples of a private constructor and a public getInstance method, and applied the double-checked locking to the latter. However, a colleague then suggested that all my other methods in the same class should also be synchronized - is this the case or am I creating an unnecessary performance bottleneck? Or have I unwittingly created that bottleneck elsewhere?
    package com.mycode;
    import java.util.HashMap;
    import java.util.Iterator;
    public class DataCache {
        private volatile static DataCache uniqueInstance;
        private HashMap<String, DataCacheElement> dataCache;
        private DataCache() {
            if (dataCache == null) {
                dataCache = new HashMap<String, DataCacheElement>();
        public static DataCache getInstance() {
             if (uniqueInstance == null) {
                synchronized  (DataCache.class) {
                    if (uniqueInstance == null) {
                        uniqueInstance = new DataCache();
            return uniqueInstance;
        public synchronized void put(String uniqueID, DataCacheElement dataCacheElement) {
            dataCache.put(uniqueID, dataCacheElement);
        public synchronized DataCacheElement get(String uniqueID) {
            DataCacheElement dataCacheElement = (DataCacheElement) dataCache.get(uniqueID);
            return dataCacheElement;
        public synchronized void remove(String uniqueID) {
            dataCache.remove(uniqueID);
        public synchronized int getCacheSize() {
         return dataCache.keySet().size();
         * Flushes all objects from the cache that are older than the
         * expiry time.
         * @param expiryTime (long milliseconds)
        public synchronized void flush(long expiryTime) {
            String uniqueID;
            long currentDate = System.currentTimeMillis();
            long compareDate = currentDate - (expiryTime);
            Iterator<String> iterator = dataCache.keySet().iterator();
            while( iterator.hasNext() ){
                // Get element by unique key
                uniqueID = (String) iterator.next();
                DataCacheElement dataCacheElement = (DataCacheElement) get(uniqueID);
                // get time from element
                long lastUpdatedDate = dataCacheElement.getUpdatedDate();
                // if time is greater than 1 day, remove element from cache
                if (lastUpdatedDate <  compareDate) {
                    remove(uniqueID);
        public synchronized void empty() {
            dataCache.clear();
    }

    m0thr4 wrote:
    SunFred wrote:
    m0thr4 wrote:
    I [...] applied the double-checked locking
    Which is broken. http://www.ibm.com/developerworks/java/library/j-dcl.html
    from the link:
    The theory behind double-checked locking is perfect. Unfortunately, reality is entirely different. The problem with double-checked locking is that there is no guarantee it will work on single or multi-processor machines.
    The issue of the failure of double-checked locking is not due to implementation bugs in JVMs but to the current Java platform memory model. The memory model allows what is known as "out-of-order writes" and is a prime reason why this idiom fails[b].
    I had a read of that article and have a couple of questions about it:
    1. The article was written way back in May 2002 - is the issue they describe relevant to Java 6's memory model? DCL will work starting with 1.4 or 1.5, if you make the variable you're testing volatile. However, there's no reason to do it.
    Lazy instantiation is almost never appropriate, and for those rare times when it is, use a nested class to hold your instance reference. (There are examples if you search for them.) I'd be willing to be lazy instantiation is no appropriate in your case, so you don't need to muck with syncing or DCL or any of that nonsense.

  • EmpApplet can't be instantiated ERROR

    Hi,I'm having the same "tutorial.EmpApplet can't be
    instantiated" problem everyone else seems to be having. I've
    tried all the recommended solutions and nothing works. Here is
    a copy of the output to the Java Console using Internet Explorer.
    com.ms.security.SecurityExceptionEx
    [com/sun/java/swing/UIManager.setLookAndFeel]:
    java.io.IOException: bad path: D:\Program
    Files\Oracle\JDeveloper 2.0.184
    Beta\myclasses\com\sun\java\swing\plaf\metal\MetalLookAndFeel.cla
    ss
    at com/ms/security/permissions/FileIOPermission.check
    at com/ms/security/PolicyEngine.deepCheck
    at com/ms/security/PolicyEngine.checkPermission
    at com/ms/security/StandardSecurityManager.chk
    at com/ms/security/StandardSecurityManager.checkRead
    at java/io/File.isDirectory
    at sun/net/www/protocol/file/FileURLConnection.connect
    at
    sun/net/www/protocol/file/FileURLConnection.getInputStream
    at
    com/ms/vm/loader/ResourceLoader.getCodebaseRelativeData
    at com/ms/vm/loader/ResourceLoader.getClassData
    at com/ms/vm/loader/URLClassLoader.findClass
    at com/ms/vm/loader/URLClassLoader.loadClass
    at java/lang/ClassLoader.loadClassInternal at
    java/lang/Class.forName
    at com/sun/java/swing/UIManager.setLookAndFeel
    at com/sun/java/swing/UIManager.initializeDefaultLAF
    at com/sun/java/swing/UIManager.initialize
    at com/sun/java/swing/UIManager.maybeInitialize
    at com/sun/java/swing/UIManager.getDefaults
    at com/sun/java/swing/UIManager.getColor
    at borland/jbcl/control/BevelPanel.<init>
    at borland/jbcl/control/ButtonBar.<init>
    at borland/jbcl/control/NavigatorControl.<init>
    at tutorial/QueryEmpPanel.<init> at
    tutorial/EmpApplet.<init>
    at com/ms/applet/BrowserAppletFrame.newInstance
    at com/ms/applet/AppletPanel.processSentEvent
    at com/ms/applet/AppletPanel.processSentEvent at
    com/ms/applet/AppletPanel.run
    at java/lang/Thread.runError loading class:
    com.sun.java.swing.plaf.metal.MetalLookAndFeel
    com.ms.security.SecurityExceptionEx
    [com/sun/java/swing/UIManager.setLookAndFeel]:
    java.io.IOException: bad path: D:\Program
    Files\Oracle\JDeveloper 2.0.184
    Beta\myclasses\com\sun\java\swing\plaf\metal\MetalLookAndFeel.cla
    ss
    com.ms.security.SecurityExceptionEx
    [com/sun/java/swing/UIManager.setLookAndFeel]:
    java.io.IOException: bad path: D:\Program
    Files\Oracle\JDeveloper 2.0.184
    Beta\myclasses\com\sun\java\swing\plaf\metal\MetalLookAndFeel.cla
    ss
    at com/ms/security/permissions/FileIOPermission.check
    at com/ms/security/PolicyEngine.deepCheck
    at com/ms/security/PolicyEngine.checkPermission
    at com/ms/security/StandardSecurityManager.chk
    at com/ms/security/StandardSecurityManager.checkRead
    at java/io/File.isDirectory
    at sun/net/www/protocol/file/FileURLConnection.connect
    at
    sun/net/www/protocol/file/FileURLConnection.getInputStream
    at
    com/ms/vm/loader/ResourceLoader.getCodebaseRelativeData
    at com/ms/vm/loader/ResourceLoader.getClassData
    at com/ms/vm/loader/URLClassLoader.findClass
    at com/ms/vm/loader/URLClassLoader.loadClass
    at java/lang/ClassLoader.loadClassInternal at
    java/lang/Class.forName
    at com/sun/java/swing/UIManager.setLookAndFeel
    at com/sun/java/swing/UIManager.initializeDefaultLAF
    at com/sun/java/swing/UIManager.initialize
    at com/sun/java/swing/UIManager.maybeInitialize
    at com/sun/java/swing/UIManager.getDefaults
    at com/sun/java/swing/UIManager.getColor
    at borland/jbcl/control/BevelPanel.<init>
    at borland/jbcl/control/ButtonBar.<init>
    at borland/jbcl/control/NavigatorControl.<init>
    at tutorial/QueryEmpPanel.<init> at
    tutorial/EmpApplet.<init>
    at com/ms/applet/BrowserAppletFrame.newInstance
    at com/ms/applet/AppletPanel.processSentEvent
    at com/ms/applet/AppletPanel.processSentEvent at
    com/ms/applet/AppletPanel.run
    at java/lang/Thread.runError loading class:
    com.sun.java.swing.plaf.metal.MetalLookAndFeel
    com.ms.security.SecurityExceptionEx
    [com/sun/java/swing/UIManager.setLookAndFeel]:
    java.io.IOException: bad path: D:\Program
    Files\Oracle\JDeveloper 2.0.184
    Beta\myclasses\com\sun\java\swing\plaf\metal\MetalLookAndFeel.cla
    ss
    java.lang.InstantiationException: tutorial/EmpApplet
    at com/ms/applet/BrowserAppletFrame.newInstance
    at com/ms/applet/AppletPanel.processSentEvent
    at com/ms/applet/AppletPanel.processSentEvent at
    com/ms/applet/AppletPanel.run
    at java/lang/Thread.run
    Please help as I am trying to prove that JDeveloper is the way
    our organization should go for Oracle development.
    Thanks,
    Joe Villarreal
    null

    Joe,
    Does the version on IE that you are using support Swing 1.1 ?
    Also, I am not sure why it is referring to the absolute path (D:
    \Program Files\Oracle\JDeveloper 2.0.184
    Beta\myclasses\com\sun\java\swing\plaf\metal\MetalLookAndFeel.cla
    ). Does your jar file have this path?
    Regards,
    Joe Villarreal (guest) wrote:
    : Hi,I'm having the same "tutorial.EmpApplet can't be
    : instantiated" problem everyone else seems to be having. I've
    : tried all the recommended solutions and nothing works. Here
    is
    : a copy of the output to the Java Console using Internet
    Explorer.
    : com.ms.security.SecurityExceptionEx
    : [com/sun/java/swing/UIManager.setLookAndFeel]:
    : java.io.IOException: bad path: D:\Program
    : Files\Oracle\JDeveloper 2.0.184
    Beta\myclasses\com\sun\java\swing\plaf\metal\MetalLookAndFeel.cla
    : ss
    : at com/ms/security/permissions/FileIOPermission.check
    : at com/ms/security/PolicyEngine.deepCheck
    : at com/ms/security/PolicyEngine.checkPermission
    : at com/ms/security/StandardSecurityManager.chk
    : at com/ms/security/StandardSecurityManager.checkRead
    : at java/io/File.isDirectory
    : at sun/net/www/protocol/file/FileURLConnection.connect
    : at
    : sun/net/www/protocol/file/FileURLConnection.getInputStream
    : at
    : com/ms/vm/loader/ResourceLoader.getCodebaseRelativeData
    : at com/ms/vm/loader/ResourceLoader.getClassData
    : at com/ms/vm/loader/URLClassLoader.findClass
    : at com/ms/vm/loader/URLClassLoader.loadClass
    : at java/lang/ClassLoader.loadClassInternal at
    : java/lang/Class.forName
    : at com/sun/java/swing/UIManager.setLookAndFeel
    : at com/sun/java/swing/UIManager.initializeDefaultLAF
    : at com/sun/java/swing/UIManager.initialize
    : at com/sun/java/swing/UIManager.maybeInitialize
    : at com/sun/java/swing/UIManager.getDefaults
    : at com/sun/java/swing/UIManager.getColor
    : at borland/jbcl/control/BevelPanel.<init>
    : at borland/jbcl/control/ButtonBar.<init>
    : at borland/jbcl/control/NavigatorControl.<init>
    : at tutorial/QueryEmpPanel.<init> at
    : tutorial/EmpApplet.<init>
    : at com/ms/applet/BrowserAppletFrame.newInstance
    : at com/ms/applet/AppletPanel.processSentEvent
    : at com/ms/applet/AppletPanel.processSentEvent at
    : com/ms/applet/AppletPanel.run
    : at java/lang/Thread.runError loading class:
    : com.sun.java.swing.plaf.metal.MetalLookAndFeel
    : com.ms.security.SecurityExceptionEx
    : [com/sun/java/swing/UIManager.setLookAndFeel]:
    : java.io.IOException: bad path: D:\Program
    : Files\Oracle\JDeveloper 2.0.184
    Beta\myclasses\com\sun\java\swing\plaf\metal\MetalLookAndFeel.cla
    : ss
    : com.ms.security.SecurityExceptionEx
    : [com/sun/java/swing/UIManager.setLookAndFeel]:
    : java.io.IOException: bad path: D:\Program
    : Files\Oracle\JDeveloper 2.0.184
    Beta\myclasses\com\sun\java\swing\plaf\metal\MetalLookAndFeel.cla
    : ss
    : at com/ms/security/permissions/FileIOPermission.check
    : at com/ms/security/PolicyEngine.deepCheck
    : at com/ms/security/PolicyEngine.checkPermission
    : at com/ms/security/StandardSecurityManager.chk
    : at com/ms/security/StandardSecurityManager.checkRead
    : at java/io/File.isDirectory
    : at sun/net/www/protocol/file/FileURLConnection.connect
    : at
    : sun/net/www/protocol/file/FileURLConnection.getInputStream
    : at
    : com/ms/vm/loader/ResourceLoader.getCodebaseRelativeData
    : at com/ms/vm/loader/ResourceLoader.getClassData
    : at com/ms/vm/loader/URLClassLoader.findClass
    : at com/ms/vm/loader/URLClassLoader.loadClass
    : at java/lang/ClassLoader.loadClassInternal at
    : java/lang/Class.forName
    : at com/sun/java/swing/UIManager.setLookAndFeel
    : at com/sun/java/swing/UIManager.initializeDefaultLAF
    : at com/sun/java/swing/UIManager.initialize
    : at com/sun/java/swing/UIManager.maybeInitialize
    : at com/sun/java/swing/UIManager.getDefaults
    : at com/sun/java/swing/UIManager.getColor
    : at borland/jbcl/control/BevelPanel.<init>
    : at borland/jbcl/control/ButtonBar.<init>
    : at borland/jbcl/control/NavigatorControl.<init>
    : at tutorial/QueryEmpPanel.<init> at
    : tutorial/EmpApplet.<init>
    : at com/ms/applet/BrowserAppletFrame.newInstance
    : at com/ms/applet/AppletPanel.processSentEvent
    : at com/ms/applet/AppletPanel.processSentEvent at
    : com/ms/applet/AppletPanel.run
    : at java/lang/Thread.runError loading class:
    : com.sun.java.swing.plaf.metal.MetalLookAndFeel
    : com.ms.security.SecurityExceptionEx
    : [com/sun/java/swing/UIManager.setLookAndFeel]:
    : java.io.IOException: bad path: D:\Program
    : Files\Oracle\JDeveloper 2.0.184
    Beta\myclasses\com\sun\java\swing\plaf\metal\MetalLookAndFeel.cla
    : ss
    : java.lang.InstantiationException: tutorial/EmpApplet
    : at com/ms/applet/BrowserAppletFrame.newInstance
    : at com/ms/applet/AppletPanel.processSentEvent
    : at com/ms/applet/AppletPanel.processSentEvent at
    : com/ms/applet/AppletPanel.run
    : at java/lang/Thread.run
    : Please help as I am trying to prove that JDeveloper is the way
    : our organization should go for Oracle development.
    : Thanks,
    : Joe Villarreal
    null

  • Ideas or help needed for a simple, robust pluggable framework

    Hi all,
    Having written a fairly decent plugin engine, similar in concept to the Eclipse plugin engine, although at a more generic scale, I am looking for any possible ideas for a Java Swing framework that is built around the engine, with the concept of using a framework that is built on mostly plugins. My engine handles, or will soon handle, a number of features to make the engine robust enough, yet still easy enough, to use for just about any purpose.
    The engine is pretty simple, although with a bit more work I feel will be overall a pretty robust and powerful plugin engine. Each plugin is made up of one or more "services". A plugin is a .jar file that contains a plugin-conf.xml config file, the classes that implement the Service interface, and any supporting classes. The "plugin" is really the package of one or more services and supporting classes. The engine will handle the ability to work with expanded dir structures as well, so that the build process doesn't have to create .jar files on every build of a plugin. The engine has built in support to load, unload and reload a plugin at runtime. This helps during development by allowing auto-reload of a plugin service without having to restart the app. The engine has the ability to "watch" URLs in a separate thread (still working on this), and at given intervals if a change occurs to any plugin, that plugin is reloaded. This is configurable on a per plugin basis in the config file.
    Every plugin .jar file gets its own classloader instance. Because of the nature of a framework that may rely heavily on plugins, it will be very common to have plugin dependencies, where a plugin service may rely on one or more other plugin services. The dependencies are configured in the plugin-conf.xml file, and the engine resolves these when the plugin is loaded, automatically. Once all plugins have been loaded, an "init" call is made that then goes and resolves all plugin service dependencies, setting up the behind the scenes work to make sure any service can use any other service it defines to depend on. Another area is plugin versions. There will no doubt be a time when some sort of application may have legacy plugins, but also have newer plugins. For example, an application built on a "core" set of plugins, may eventually update the core plugins with newer versions. The engine allows the "old" plugins to exist and work while new versions of the same plugins may be loaded and working at the same time. This allows older plugins that depend on the old set of core plugins to work, while newer plugins that depend on the new core plugins may work also. Any plugin may depend on one or more services specified by specific versions, or a range of versions.
    Plugin services can define to be created when first loaded, or lazy instantiated. Ideally, an application would opt for lazy instantiation until a plugin is needed. For example, a number of plugins may need to add menu items or buttons that would trigger its service. The plugin does not actually need to be created until the menu or button is clicked on. There is one BIG problem with how this engine works though. Unlike the Eclipse (and other) engines where the config file defines the menu item(s), buttons, etc in an xml sort of language, this engine is built for generic use, and therefore is not specific to menu items or buttons triggering a service instantiation. Therefore, a little "hack" is required. A specific plugin that is created when first loaded will be required to set up all the menu items for specific plugins, then handle the actionPerformed() call to instruct the engine to create the service. The next step would be for the plugin service to add its own handler to the specific menu item it depends on, and remove the "old" handler the startup plugin added to it to handle the initial click. Another thought just struck me though. Because the engine must use an XML parser to load every plugin-conf.xml file, it might be possible to "extend" the parsing routine, where by an extending class could be added to the engine to parse plugin-conf.xml files. First the plugin engines own routine would parse it. Then, the extending class could parse for any extra plugin-conf.xml info, such as menu item settings, and directly set up the menu items and handlers in this manner. I will probably include this ability directly in the engine soon anyway, so that nobody else has to do this, but this is one area I would appreciate some feedback on.
    Anyway, so that is the jist of the engine. There is more to it under the hood, but that sums up a good part of it. Now, the pluggable framework, much like what the "shell" of eclipse, forte and so forth offer, is built around my engine to make it very easy to build Swing applications with a pluggable framework underneath. The idea is to package up a startup main class that is configurable, a number of useful plugins that other plugins could depend on, such as an Outlook layout, menuing, toolbars, drag/drop, history, undo/redo, macro record, open/save/search/find/replace dialogs, and so forth. This isn't just for an IDE though. The developer using the framework could deploy the basic app with the plugins of his/her choice, and add to it with his/her own plugins.
    Soooo, after this long post, what I am getting at is if anyone would be interested in helping out with ideas, feedback, testing, core framework plugins, and so forth. At this time I am keeping the code closed, but will probably public domain it, open source it, or whatever. The finished framework should make it easy for anyone to quickly build useable applications, and if all goes well, I'd like to set up a site with a location for 3rd party plugins to be uploaded, for download, comments, etc. Being a web developer, I myself will probably work on some plugins for Web Services, web stress testing, and so forth. I have lots of ideas for useable plugins.
    On that note, one application I am personally working on for my own use, is a simple yet possibly robust internet suite of apps. I want to incorporate FTP, Email, NewsGroup, and IRC/AOL IM/Yahoo IM/MSN IM/ICQ chat into a single app. Every aspect of it would be plugins. Frankly, I hate outlook, Eudora is alright, but I want to do some things with the email app. I also want a single IM/Chat app that can talk with all protocols (not an easy task, take a look at GAIM). Newsgroups are handy to work with for developers and others of interest, as is FTP. But even more so, being able to have all in one big application framework that allows them to share data between each other, work with one another, and so forth is appealing to me, and being written in Java it could potentially work on many platforms, giving some platforms a possible nice set of internet apps to use. Being able to send an email to a mailing list AND have it posted to specific newsgroups at the same time without having to copy/paste, open up separate applications and so forth has appeal. Directly emailing from any chat or newsgroup link without another app starting up is a little faster as well. Those are just "small" things that could prove to be very kewl in a complete internet app. Adding a web browser, well, I don't think I want to go that route. But if there is already a decent Java built web browser, it shouldn't be too hard to add it as a plugin.
    So, if anyone is interested, by all means, drop a post to this thread, let me know of interest, feedback, ideas, point out bad things, and so forth. I appreciate all forms of communication.
    Thanks.

    Yes I do. I am using it now with my work related project.
    I am in fact reworking the engine a bit now. I want to incorporate the notion of services (like OSGi) where by a plugin can register services. These services are "global" in scope, meaning any plugin may request the use of a service. However, services, unlike plugins, are not guaranteed to be available. Therefore, plugins using services must be coded to properly handle this possibility. As an example, imagine an email application using my engine. One plugin may provide the email gateway, including the javamail .jar library and provide the email service. Other plugins, such as the one that provides the functionality for the SEND button, would "use" this service. At runtime, when the send button was pressed it would ask the engine for the email service. If available, off goes the email. If not, it could pop up a dialog indicating some sort of message that the email service is not available.
    I am at the VERY beginning stages in this direction so I'd love to have ideas, thoughts, suggestions as to how this might be implemented. I do believe though that it will provide for a more powerful engine. The nice thing is, while the engine will support static runtime plugins, it will also support dynamic services that can come and go during the runtime. The key is that plugins using services do not maintain references to them, but instead query the engine each time a plugin needs to use a service.
    Static plugins are those that are guaranteed to be available or if not, any dependent plugin is not allowed to load. That is, if A depends on B and B is not able to be loaded, A is unloaded as well as it can't perform its job without B; it depends on B in some manner to complete its function. Imagine a plugin adding an option panel to the Preferences page only that the Preferences plugin is not loaded. It just can't work. However, with some work, there could be variations on this. That is, a plugin may provide a menu item as well as a preferences page. If the preference plugin is not available, then the plugin may simply still work via the menu item, but have no preferences panel available. This should be configurable via the plugin-conf.xml config file. However, as I have it now, using extension points and extensions like Eclipse does, it is also possible that if the Preferences plugin isn't loaded, it wont look for ANY extensions extending its extensino point, and therefore the plugins could all still run but there would simply be no preferences page. So, I am not entirely sure yet which way is best for this to work.
    My engine, as it stands now, allows for separate classloader plugin loading, it automatically resolves all dependencies by creating the plugin registry each time the engine is started up. To speed up plugin loading, it maintains a plugins.xml file in the root dir that keeps track of each plugin that was loaded and its last timestamp. Plugins can be open directory files or jarred up into .PAR files (think .WAR or .EAR files). The engine can find .par or open-dir plugins in multiple locations (including URL locations for direct .par files). When it finds a .par file, it first decompresses the .par file to a plugin work directory. Every plugin must have a plugin-conf.xml in its root dir, and either a /classes dir where compiled classes are, or a .jar file in the root path of the plugin, where the /classes dir superscedes the .jar file. Alternatively, anything in a /lib dir is automatically picked up as part of the plugin classpath. So a plugin that wraps the xerces.jar file can simply place the xerces.jar in the /lib dir and automatically present the xerces library to all dependent plugins (which can import the xerces classes but not need to distribute the xerces.jar file if a plugin they depend on has it in its /lib dir). The "parent lookup" process goes only one parent level deep. That is, if plugin A depends on a class in a /lib/*.jar file in plugin B, then the engine will resolve the class (through delegation) of plugin B. But if A depends on B, B depends on C where plugin C's /lib/*.jar file contains a class A is looking to use, this will not work and A will throw a ClassNotFoundException. In other words, the parent lookup only goes as far as the classpath of all dependent plugins, not up the chain of all dependent plugins. Eclipse allows each plugin to "export" various classes, or packages, or entire .jar files and the lookup can go all the way up the chain if need be. I haven't yet found a big reason for supporting this, so I am not too concerned with that at this point. The engine does support reloadable plugins although I have not yet implemented it. Because each plugin information object is stored in a Map keyed on the plugins GUID (found in the plugin-conf.xml file), it is easy enough to load a new plugin (since they get their own classloader) and replace the object at the GUID key and now have a reloaded plugin. The harder part is properly notifying all dependent plugins of the reload and what to do with them. Therefore I have not quite yet implemented this feature although the first step can easily be done, so long as nobody minds the "remnants" of older plugins laying around and possibly not being garbage collected.
    All of this works now, and I am using it. I do NOT have a generic UI framework just yet. I am working on that now. Eclipse has a very nice feature in that every plugin.xml file builds up the UI without any plugin code ever being created or ran. I am working on something like that now, although I am focussed more on the aspect of the engine at this point.
    Two things keep me going. First, the shear fun of working on this and seeing it succeed, even if a little bit. Second, while I love the idea of Eclipse, OSGi and other engines, so far I have yet to find one that is very easy to write plugins for, is very small, and is "generic" enough for any use. Some may argue JBoss core, at 29K can do this. I don't know if it can. It is built around JMX and I don't know that I agree JMX is the "ultimate" core plugin engine for all types of apps. Not that mine is either, but I'd like to see what I am working on become that if possible. Currently, with an xml parser (www.xmlpull.org) added as part of the code, my engine is about 40K with debug info, maybe about 28K without. I expect it to grow a bit more with services, reloadable/unloadable code, and some other stuff. However, I am thinking it will still be around 50K in size and in my opinion, with an xml read/write parser (very fast one at that), extension/extensino points, services, dependencies, multiple versions of plugins (soon), load/unload/reload capabilities, .par management (unjar into work dir, download .par files from urls, etc) and open directory capabilities, inidividual classloaders, automatic dependency resolution, dynamic dependency resolution and possibly even more, I think what my engine offers (and will offer) is pretty cool in my book.
    None the less, there is always room for improvement. One of the things I pride myself on is using as little code and keeping the code neat and easily readable, not to mention as non-archaic as possible, makes for an easily maintainable project.
    So, having said all that, YES, the engine can be used as is right now. It does not reload plugins, but you can dynamically load plugins, handle dependency resolution, have a very fast xml read/write parser at your disposal for any plugin, and for the most part easily write plugins. That is all possible now. I should put the engine I have now up on my generic-plugin-engine sourceforge project one of these days, perhaps soon I will do that! While I have no problem handing out the code, I am currently the only committer and I don't have it loaded into CVS at this point. I would like to do so very soon.
    So, if you are interested, by all means, let me know and I'll be happy to send you what I have, and love to have more help on the next version of this.

  • Synchronizing Creation of a Singleton Object

    I've encountered a synchronization issue I haven't seen covered in the material I've read so far. My server app uses message driven beans that maintain a variety of lookup tables (maps, actually), to do data validation. Each map is a singleton, and is created with lazy instantiation (i.e., not created until requested the first time). The problem is this: I want to prevent one thread from trying to read the map while another is creating it. Until the map is created, there's nothing to synchronize, but after it's created, there's no point in synchronizing either, because it will never change. The only time I need synchronization is during the one time the map is created. I don't want to synchronize later accesses to the map, for performance reasons. The code examples I've seen so far don't address this particular issue. Here's a code snippet of how I'm thinking of implementing this. Any comments or criticisms would be greatly appreciated.
    This code is from the the superclass of my data validation classes. The design is that a thread/bean needing map access would call getMapIfNeeded(), then do the lookup. The buildMap() method calls a separate, unsynchronized database class
    * Builds the lookup map if it doesn&rsquo;t already exist.
    * @param attribute Name of the attribute in table <span class="oracle">efm_accp_valu</span>.
    * @param map Map against which we&rsquo;ll validate values. If non-null, nothing is done.
    * @return The map (newly created if the input argument was <code>null</code>).
    * @throws APISystemException If a serious system error occurs.
    * @see #getListIfNeeded(String, List)
    protected static Map getMapIfNeeded(final String attribute, Map map)
       throws APISystemException
       if (map == null)
          map = buildMap(attribute);
       return map;
    * Builds the lookup map if it doesn&rsquo;t already exist.
    * @param attribute Name of the attribute in table <span class="oracle">efm_accp_valu</span>.
    * @param map Map against which we&rsquo;ll validate values. If non-null, nothing is done.
    * @return The map (newly created if the input argument was <code>null</code>).
    * @throws APISystemException If a serious system error occurs.
    * @see #getListIfNeeded(String, List)
    protected static synchronized Map buildMap(final String attribute)
       throws APISystemException
       return AcceptableValueDAO.getMap(attribute);
    {code}

    After doing some more research, I've concluded that, in my scenario at least, a better solution is to create the maps in static blocks. This avoids synchronization issues altogether, with the disadvantage being that if a database exception is thrown in the static block, I can't do much except print the stack trace. If anyone knows better, don't be shy about speaking up!

  • Object Serialization(Materialization and Dematerialization)

    I've encountered some issues with mapping my objects to an RDBMS and am hoping for some advice.
    I've tried various O/R mapping frameworks like Castor(too complex and too slow for my liking), JRF(nice but very repetitive and difficult to extend) and then some, but have yet to find one which I'm comfortable with building an application on.
    Instead, I've chosen to do it the low-tech way, with each domain class, say Book for instance, having a Broker class which knows how to communicate with the chosen form of persistence. So, since I chose an RDBMS, Book class has a BookRelationalBroker class which knows how to materialize and dematerialize Book objects to and from a RDBMS. If so required, I can plug in a BookXMLBroker which knows how to serialize the object in the form of an xml data file.
    I've also implemented a primitive object caching system which (when enabled), caches objects requested so we only have to materialize it from the db once.
    Here are 2 issues I have with my system:
    It is amazingly tedious (not to mention inefficient) to recreate the entire object from the database. This is even more so because I've implemented the Event Notification pattern, such that when say a book is deleted, the members who have reserved it are notified. The whole point of the Event Notification mechanism is so that the object being watched does not need to know of the objects which need to be notified on a state change. However, I've found it necessary to re-attach all the listeners on an object when it is materialized from the DB, defeating the purpose of the pattern.
    Complex object relationships are mapped poorly and recursive materialization leads to slow response times. If a Group object has a Vector of Members and other Groups, then whenever a Group object is materialized, all its constituent Members and Group objects also need to be materialized. (I understand O/R frameworks solve this through lazy instantiation)
    I studied the Jive2 architecture and found that they approached this problem by accessing the DB directly for any complex object relationships. In other words, the Group object does not actually contain a Vector of Members and Groups. Instead, it has a method called say getMembers() which proceeds to retrieve the necessary data from the DB and then materialize these objects.
    I'm not too excited about this approach for 2 reasons:
    How object-oriented is this approach? Seems more like database-oriented programming to me.
    Every call to retrieve Members necessitates a call to the DB. The data isn't cached with the Group object because the Group object does not actually contain the necessary reference to the Members and Groups.
    Can anyone shed some light on this topic?

    How object-oriented is this approach? Seems more like database-oriented programming to me. There is a reason people still use Relational databases rather than OO DBs. First, is that the vast majority of data in the real world maps easily to a relational model, consequently there is no advantage to a OO model. Second, either because of this or simply because OO models are not computationally simple, OO databases tend to be slower than relational DBs.
    It sounds like you are trying to implement a OO DB model using a relational database. So you basically end up with two problems. The DB is not optimized for OO models, and you have to find a way to map it in the OO model itself. And this is slow and messy.
    To solve the slowness problem you could, just like EJB servers, cache the data in memory. Lot of work but if you want to do it then have fun.
    The second way is to give up. Realize that your data model is not inherently OO'd and just implement it efficiently as a relational model. Then provide an interface that loads it into the OO model. And where needed add pass through logic to allow the database itself to do things it is really good at - like queries.

  • Help: Design Issues in Swing

    Hi Friends
    I developed an application in swings way back in 2000-01. However then there were serious issues of Memory leakage with Swings. Hence the strategy we adopted was to use a cache of Swing components rather than creating new objects everytime.
    Now again in 2004, i am back to swings.
    Now are there still issues with the swings?
    What are the other things, we need to keep in mind during the design?
    I heard that listeners create problem with the components since component get registered with the Listeners and are not able to get released.
    And there are problems of lot of internal objects being created.. Is this true.. if yes.. how do we tackle the problem??

    hi,
    I'm using swing in some programs of my own, and I've not experienced any serious problems yet.
    Some points need to be mentioned however:
    - Instantiating heavyweight components (such as JFileChooser) tends to be slow, try instantiating only one JFileChooser for your application and reuse it by just hiding/showing it.
    - Most programs instantiate all their components (visible and invisible) at startup. This slows down the startup time and the performance feeling of your program. Try using lazy-instantiation (do not initialise the component at the beginning but only initialise the component when it is called upon for the first time). Some more specific instantiation-schemes can be used, for instance for image- or sound-loading.
    Of course the splash-screen with small animations tends to ease the pain to wait for the user.
    - caching can also be used to improve performance, but here I think you should always first measure the performance of the component to be cached (using a profiler). Using a cache on a well performing object might also reduce it's performance.
    To reduce the memory-footprint of the cache, you could combine it with the lazy-instantiation and perhaps even use WeakReferences to hold this objects in order not to let the cache be a memory-bottleneck.
    This can be especially useful when using large quantities of equal objects (what also happens for String) or when using a decent amount of very memory-consuming objects such as images.
    Normally (for the remaining optimization) it is adviced to not optimize while programming, and only start to optimize for performance and memory usage when problems show up. For doing this you should use some serious profiler, instead of blindly optimizing what seems slow.
    Also try reading the book about java performance which can be found using the link below:
    http://java.sun.com/docs/books/performance/1st_edition/html/JPTOC.fm.html
    This book gives many of the advices I've given above and explains the total process of performance-tuning. Another advantage of this book is that it uses Swing as an example for it's optimizations, and that the author has cooperated in programming (parts of) Swing.
    Kind regards,
    Koen

  • Development Performance Guidlines

    Could you please send me information if you know about guidlines for J2EE developers regarding performance.
    We will develop client desktop application running in browser and communicating with application server BEA WebLogic.

    do you mean tips for better performance?
    Yes:
    use the business delegate pattern
    use the session facade pattern
    avoid lots of round trips (it's better to send a small number of large messages than a large number of small messages)
    have the client keep track of most/all of the application's state
    use lazy-instantiation or proxies where appropriate
    Read:
    Patterns of Enterprise Applications (Fowler)
    J2EE Design Patterns
    EJB Design Patterns
    the GoF patterns book
    Best Practices:
    write your code to be maintainable and very loosely coupled
    have a DBA tune your table structures and SQL
    use a performance tuning tool to spot performance troubles
    tune those areas specified by your tool (the loosely coupled nature of your implementation should allow you to make these changes rather easily)
    don't pre-emptively tune: you'll spend too much time chasing things that aren't actual performance problems.

Maybe you are looking for