Initializing a class automatically at application loadtime, howto?

Hi,
In a web application deployed on an application server, i can automatically initialize a servelt at application loadtime by using the following in my web.xml
    <servlet>
        <servlet-name>classRefName</servlet-name>
        <servlet-class>myPackage.myClass</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>classRefName</servlet-name>
        <url-pattern>/path/To/myClass</url-pattern>
    </servlet-mapping>... now i want to initialize an ordinary class at startup time of the web-application. How can i get the same effect?
I know that i can code my class as a servlet (and initialize it as shown above) but that doesnt look elegent at all and i am looking for a neat solution (if possible).
Any pointers? anyone?
regards,
mnsharif

oh!!
i looked at the API and that was so simple!
thanks a lot steve, you saved a lot of my time and effort!!
cheers!

Similar Messages

  • Howto find entity-classes in my application?

    I need to get hold of all entity-classes in my application. For now, I only use annotations(@Entity) but I may change to write XML-mapping files. :)
    Does some have a clue how I should get hold of my entities?

    What do you mean by "get hold of"?
    Wouldn't it be sufficient to grep your source code for "@entity" ?

  • How to invoke java class automatically at a fixed time everyday

    How to invoke a java class automatically using Quartz scheduler or any other simplified way
    I am trying to schedule a job in my web application and need to understand conceptually How to make it work using quartz . The job is scheduled to be executed at 4 pm daily. Am testing the same and It works well when i run it as standalone application manually.
    How to configure it that when i start my aplication it should run at its own through quartz.
    I am avoiding use of servlet init method and java timer though any alternatives there?
    Thanks for your help.

    I've not see quartz... are you in Windows, Solaris, Linux, or Mac?
    Are you using JAR files or class files?
    Windows: javaw myClass (I cannot remember right off if you have to have the .class on the end)
    Windows: java -jar myJAR.jar
    Solaris java -jar myJAR.jar
    Linux java -jar myJAR.jar
    Mac?

  • Recursive generic classes - Automatically assign default class?

    Hello,
    I'm working on a kind of ArrayList with some extra features... (named FullRangeList)
    To realize this, I need a way to create a new Object of my generic type for the current instance.
    Basicly, it works for me as described here: http://forum.java.sun.com/thread.jspa?forumID=31&threadID=5221886
    But in my case, my generic type will very often be the very same class, and I want my class to set its default class automatically.
    Here is my code:
    public class FullRangeList<E>
      private Class<?> defaultClass;
      public void setDefaultClass(Class<?> def)
        this.defaultClass = def;
      @SuppressWarnings("unchecked")
      public E getOrCreate(int index) throws Exception
        E elem = this.get(index);
        if (elem == null)
          if (this.defaultClass == null) throw new Exception("Cannot create Default Element: no default class set");
          try
            elem = (E)this.defaultClass.newInstance();
            if (elem instanceof FullRangeList)
            { // <- Here is the problem ;-)
              //elem.setDefaultClass(foo);
            this.set(index, elem);
          catch (Exception e)
            e.printStackTrace();
        return elem;
    }There are two problems now:
    1. I have no idea how to get to know what foo should be.
    if defaultclass is FullRangeList<FullRangeList<String>> foo is FullRangeList<String>... but how to realize that?
    2. It turns out that I have to cast elem in order to use ist.
    ((this.defaultClass)elem) causes a "Syntax error on token "elem", delete this token"-Error... what's wrong about that?
    hope anyone can help...
    nafur

    nafur wrote:
    I want the "getOrCreate" method to fetch an item and, if it has not been created yet, to create it.
    For this, I need the class, and that works so far.
    But what, if E is again a FullRangeList?
    Then, this child would need a default-class too!
    If I have a FullRangeList<FullRangeList<FullRangeList<SomeObject>>> list, i would say "list.setDefault(Class<FullRangeList<FullRangeList<FullRangeList<SomeObject>>>>)"
    But how do I get to know in my code, that a child of list should get "Class<FullRangeList<FullRangeList<SomeObject>>>" as default class?
    and their Childs "Class<FullRangeList<SomeObject>>"?As spoon_ already mentioned, there are no generic types at runtime. Working with reflection targets runtime, so no Generics.
    Another point is, that there is no FullRangeList<SomeObject>.class but only a FullRangeList.class. Hence, what you desire does not make sense in Java.
    Reading your approach, I would suggest working with some factory approach rather than implicit contracts on parameters given. Initializing the FullRangeList with some factory would provide what you need.

  • I want to create Automatic mailing application, help!.

    hi all,
    i m given an assignment to develop an automatic mailing application.
    i this app. each newly registered user is being sent an email to email addr specified by him. this mail will be an acknowlegement to his registration.
    email to be sent is an dynamic jsp file.
    plz give any idea hw to do that.
    thanx

    import java.util.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    // Send a simple, single part, text/plain e-mail
    public class TestEmail {
    public static void main(String[] args) {
    // SUBSTITUTE YOUR EMAIL ADDRESSES HERE!!!
    String to = "";
    String from = "";
    // SUBSTITUTE YOUR ISP'S MAIL SERVER HERE!!!
    //Straing host = "smtp.yourisp.net";
    String host = "smtp";
    // Create properties, get Session
    Properties props = new Properties();
    // If using static Transport.send(),
    // need to specify which host to send it to
    props.put("mail.smtp.host", host);
    // To see what is going on behind the scene
    props.put("mail.debug", "true");
    Session session = Session.getInstance(props);
    try {
    // Instantiatee a message
    Message msg = new MimeMessage(session);
    //Set message attributes
    msg.setFrom(new InternetAddress(from));
    InternetAddress[] address = {new InternetAddress(to)};
    msg.setRecipients(Message.RecipientType.TO, address);
    msg.setSubject("Test E-Mail through Java");
    msg.setSentDate(new Date());
    // Setting message as text content
    //msg.setText("This is a test Mail from Java");
    // Setting message as html content
    msg.setContent("<div style='background-color:blue'>This is the test HTML content</div>","text/html;charset=\"UTF-8\"");
    //Send the message
    Transport.send(msg);
    catch (MessagingException mex) {
    // Prints all nested (chained) exceptions as well
    mex.printStackTrace();
    }//End of class

  • ?Is it possible to create a javafx class without extending Application class ? If yes, how

    Is it possible to create a javafx class without extending Application class ? If yes, how ?

      There is no  such thing as a javafx  class.  It is a regular  java class.  The Aapplication class is  the entry
    point  for JavaFX application.  You have to extend the Application class to create Javafx  application .

  • Calling a method from custom Class in WD Application

    Hi,
    I wrote a piece of code in method SEARCH for my WD Application.
    Instead of diectly callling the method I would like to create a class and then call the method.
    How do we proceed?
    Do we use SE24 first or can we start creating class from WD application itself?
    Rgds
    vara

    Hi Vara,
    Either way it is possible if you are creating from web dynpro then you can create  assistance class from component properties there you can write one method and to access that method always you have an instance wd_assist.
    From se24 create a class and declare a method. if you declare level of method is instance then you have to create object first in application and then access your method using created instance.

  • Payment File download automatically to Application sever

    Hi ,
      We have copied a  file format for MT110 and created a new format by changing some tags using event function modules.The output is showing as per our requirement.But we want this format to be downloaded to application server once payment run/print button is pressed. we are able to see the format in DME administration but our requirement is to download automatically to application server with proper naming convention.
    Can anybody help me on this issue ?
    Thanks in advance ,
    Joby

    Hello Joby ,
    you need to 2 steps :
    1.Create a Variant for you DMEE Format in Tcode FBPM/ Program SAPFPAYM...here u have option to assign file system name for output.
    2.Assign your variant to DMEE Format in Tcode OBPM4.
    regards
    Prabhu

  • Class Component in Application area for Invoices & Dunning

    Hi friends, can anyone help me to know the class components of Application area while creating new tabs,
    For example- In that CIC screen, I want's to create a tab like Invoices & Dunning in application area, but the thing is I can't find the class component for the both Invoices & Dunning, I was searched in full class component detail description, I cn't see & find this, plz help me to know this, I would be great full to me.............

    Prince,
    I used all possible components and profiles for the Customer overview in Application area.
    I am happy with the two options.
    Case 1:
    Component - NAV_VIEW
    Profile - ISU
    Result - I am getting the following information in the screen.
    - Premise
    - CA
    - Contract
    - Installation
    - Device
    I am happy with this but the problem is I am not getting BP details.
    Case 2
    Component - NAV_VIEW
    Profile - ISU_DRG
    Result - I am getting the following information in the screen.
    - BP
    - Premise
    - CA
    - Contract
    - Installation
    - POD
    - Switch Document
    The problem is I am not getting Device details and also POD is not required.
    Please suggest.

  • Binding variables of application class in bsp application.

    Hi,
    I know it is possible to bind the variables of model class like "//MODEL/VARIABLE" but is it possible to bind the variables of applicaiton class?
    Thanks and regards,
    Santosh.

    You have to remember that BSP evolved over several releases.  In 6.10 BSP released with no support for MVC - just the Application class. The application class was simply the way to share values between views and store them between requests in stateful applications.  It doesn't support any data binding.  In 6.20 BSP began to support MVC with the introduction of controller classes and model classes.  You data bind UI elements directly to model attributes only.  There is no concept of context.
    WD is completely different in that you only data bind UI element to the a context. The MVC structure is much cleaner because the view layout never has visibility to the model (regardless of what you consider the model). 
    Over time the assistance class has become the defacto standard for models in WDA, because unlike WDJ there is no direct model object.  It originally was intended mostly as a way of having text elements for WDA components.  However it is still perfectly acceptible to use service calls (proxy objects, function modules, class methods) as your model. I personally prefer to always wrap calls to my service object up in an assistance class for clear design.

  • How can I disable the system feature which automatically restarts applications i had open during a previous session ?

    How can I disable the system feature which automatically restarts applications i had open during a previous session ?

    When you log out, uncheck the box to reopen applications. If you're still using 10.7.3, then you will have to uncheck the back with each shutdown or restart.
    10.7.4 update was suppose to fix it that when you uncheck the box, it should remain unchecked for restarts after that.
    For the resume features, check this link:
    http://reviews.cnet.com/8301-13727_7-20083707-263/managing-mac-os-x-lions-applic ation-resume-feature/?tag=mncol;title

  • Run Servlet Class on Sun Application Server  PE 9.0

    Hi,
    I have a problem to run an servlet class on Sun Application Server PE 9.0.
    My directory struture are given below :-
    C:\Sun\AppServer\domains\domain1\docroot\WEB-INF\classes\test.class
    C:\Sun\AppServer\domains\domain1\docroot\WEB-INF\web.xml
    please give me answer in detail.

    Did you web archive the WEB-INF into .war file and then deployed it with AppServer admin console?

  • How to automate flex application

    I have a Flex Application that needs to be automated using tools like HP's QuickTest Pro (QTP) or something. However, QTP requires that you write some custom code if you wish to automate some home-made components... Unfortunately, we have some 3rd-party components which we do not have the source code so we can't really the custom code without having the 3rd-party component's source code and we cannot add some additional SWC files or some other files into the application to automate it. the application is already compiled and we have only the executable file.
    how to automate flex application in above case. it is not possible to add any sort of code to application so can we add some sort of plugin to existing testing tool to automate flex. is there any plug-in available for that and for which tool?
    Any ideas?

    What do you want to automate? Essbase has several different ways of automating functionality including Esscmd, Maxl and several different flavors of APIs (C / VB / Java). The tool you would choose to automate with depends on what you are trying to do.
    If you post more specifics, we could direct you to which tool would be most appropriate and can refer you to the proper docs to get started.
    Tim Tow
    Applied OLAP, Inc

  • Is there any way to automate purging Application Logging in azure storage account tables

    is there any way to automate purging Application Logging in azure storage account tables
    Rohit Pasrija

    hi Rohit,
    If you want to delete old data automatically, I think you need develop this feature by yourself. You could code the logic methods on your project, and set a timer to execute the methods to delete old data. Please refer to this thread (http://stackoverflow.com/questions/13602629/is-it-possible-to-acces-a-table-storage-in-azure-from-an-azure-web-site
    ), you could operate table storage data using azure sdk or REST API.
    Please try it.
    Regards,
    Will
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Automatically backup application

    Is it possible to automatically backup application without a human assistance (I mean in some script running 01:00 by cron). Wget, any other tools? Is the backup URL persistent or not?

    Have a look at this Utility from HTML DB Studio:
    http://htmldb.oracle.com/pls/otn/f?p=18326:44:::::P44_ID:1462
    You can schedule this to run via cron (Unix/Linux) or as a Scheduled Job in Windows.
    Although this is not officially supported, it works perfectly - I run it at least 1 time a day to back up all of my applications at the end of the day and just before I do something irreversible.
    Thanks,
    - Scott -

Maybe you are looking for

  • Report personalization issue..

    Hi Experts, We have published our few reports which are orignially created in Query designer in our BW portal using the WAD iviews. We have a issue that when we choose "Personalize Web application"  for a report then same reports opens up every time

  • See R/3 Quotes and Orders in CRM 7.0 front end

    Hi friends, Assuming if a new CRM system is being setup, and we connect it to backend ECC sytem - Can we see in CRM the already created Quotes and Orders for a given Customer Account in R/3. After the CRM  system is setup, all the customer master acc

  • How to make new stationary in Mail

    Hi there.    I am trying to make a new mail template to send out some company info.  I understand the principal of creating an email then >save as Stationary but I can only put images left center or right.  I would like to create something close to t

  • Floppy drive install to portable USB HDD & Floppy to boot from

    title pretty much says it all. I have a resonably old computer that cant boot off of usb. and i want to install it to a usb hdd. I dont have a cd drive so i will have to use the floppy network install (i did this before).  This is the only distro tha

  • PO can be created even if PR is not released

    Hi, I am facing an issues as follows after upgrade to ECC.60 from 4.6C After creating a PR though it is picking a correct release strategy & PR is not released I can create PO with reference to PR. But if I try to create PR which is created before up