Custom Annotation :: inject object at runtime

I would like develop a custom annotation to inject object at runtime. The annotation will work as follows
1. develop ValidatorClass annotation on type.
2. If annotated on a type object will be created at runtime and injected to the object. e.g. in class A it will inject validatorimpl object to vald object/
Please let me know how to implement that.
package com.debopam.validate
public interface validator{
public String validate();
package com.debopam.validate
public class validatorimpl implements validator{
public String validate(){
   return "true";
pckage com.debopam
public class A{
@ValidatorClass(name="com.debopam.validate.validatorimpl")
validator vald;
}

yogeshd,
It might be that the .class file for the annotation that you are compiling against is the one you have given us the source code for above, but when you run the program, the class file for the annotation is not the same, and is one that was compiled before you added the static field.
This can happen if your classpath is wrong. (and would explain why the problem only occurs sometimes - because it is only failing when the classpath is wrong).
If you run the following program with the Fully qualified name of your annotation as the argument, and with the same classpath as you run your program, it can tell you where it is finding the annotation class file. Check that this is the same one that you are compiling to.
class WhereLoaded {
    public static void main(String[] args) {
        Class theClass=null;
        if(args.length > 0) {
            try {
                theClass=Class.forName(args[0]);
            } catch (Exception e) {
                e.printStackTrace();
                theClass=Object.class;
        } else {
            System.out.println(
                "The first argument should be a fully qualified class name," +
                " using java.lang.Object instead"
            theClass=Object.class;
        String name=theClass.getName();
        name=name.substring(name.lastIndexOf(".")+1) + ".class";
        System.out.println(name + " loaded from " + theClass.getResource(name));
}regards
Bruce

Similar Messages

  • Custom Annotation showing Error: is missing clinit

    Hi!
    I have created some custom annotations for use in my project. Sometimes they show error: is missing <clinit> and sometimes they don't. I'm confused. If I create a jar and use that jar in another project this error appears at compiletime .
    Here is the source of one of my custom annotations....
    import java.lang.annotation.ElementType;
    import java.lang.annotation.Retention;
    import java.lang.annotation.RetentionPolicy;
    import java.lang.annotation.Target;
    * User: yogeshd
    * Date: Mar 30, 2007
    * Time: 10:54:31 AM
    @Constraint
    @Retention(RetentionPolicy.RUNTIME)
    @Target(ElementType.FIELD)
    public @interface ConstraintMaxIntValue {
    public Validator validator = new MaxIntValidator();
    int value() default 0;
    The strange thing is that this error doesnot appears all the time...
    If anyone can explain the reason I will be enlightened. ;) thnx.

    yogeshd,
    It might be that the .class file for the annotation that you are compiling against is the one you have given us the source code for above, but when you run the program, the class file for the annotation is not the same, and is one that was compiled before you added the static field.
    This can happen if your classpath is wrong. (and would explain why the problem only occurs sometimes - because it is only failing when the classpath is wrong).
    If you run the following program with the Fully qualified name of your annotation as the argument, and with the same classpath as you run your program, it can tell you where it is finding the annotation class file. Check that this is the same one that you are compiling to.
    class WhereLoaded {
        public static void main(String[] args) {
            Class theClass=null;
            if(args.length > 0) {
                try {
                    theClass=Class.forName(args[0]);
                } catch (Exception e) {
                    e.printStackTrace();
                    theClass=Object.class;
            } else {
                System.out.println(
                    "The first argument should be a fully qualified class name," +
                    " using java.lang.Object instead"
                theClass=Object.class;
            String name=theClass.getName();
            name=name.substring(name.lastIndexOf(".")+1) + ".class";
            System.out.println(name + " loaded from " + theClass.getResource(name));
    }regards
    Bruce

  • Populating a authorisation object at runtime...

    Hi,
    how to populate a authorisation object at runtime? is it possible to have a variable etc that can be populated a runtime?
    I have a object zsales_off which has different values for different users. i need to create separate roles just to have different values for sales office for different users. i would like to avoid this by having a single role with the zsales_off getting populated at runtime.
    Details steps with code will be appreciated.
    thank you.

    Hello AHP,
    i am not still very clear about the detailed steps to be carried out as i am a novice in abap.
    i have created the authorisation variable and am using it in the query. if i manually assign values for sales office in the role, it is working fine.
    i want to assign values at run time. i am confused with the process as such.
    few doubts like:
    1> the variable should be of "authorisation" processing type or "customer exit" processing type.
    2>what to use I_step=0 or I_step =1? how to use? where to use?
    3>to write a abap code or use a func module, which one? how to use.
    any example(like in my case different sales office values for diffrent users) with DETAILED STEPS & CODE would be appreciated.
    also i need to have multiple single values for each user(but not interval).
    Please help.

  • PDF Custom Annotations Types?

    Can some kind reader comment and/or point to documentation on PDF's Custom Annotation Types?
    I was first introduced to those by Aandi Inston's reply to my "Click to Dial Plugin" posting.
    Unfortunately, such posting seems to have been pulled (lost?, relocated?, bitbucketed?) from the forum.
    My objective is to programmatically insert several links of different types in my PDF files. I intend to have a type for voice phone numbers, another for fax numbers, and yet another company or client ID, etc.
    The part below refers to a plugin (to be written).
    Later on, when the user clicks on a phone number, a call will be placed, clicks on a fax number will result in the document being faxed, while a click on an ID will result on a database lookup.
    I don't want to go through the hassle of studying the page's geometry to determine whether a phone number is voice or fax. I am just looking for a way to mark the different links, giving each one of them a type, which will be passed to the plugin upon a link being clicked.
    I recall that Aandi's explanation made an exact match for my application, but as I said before, his posting is gone.
    -Ramon

    Perhaps the use Custom Annotation Types (CAT) is an overkill? It seems that when a CAT is defined, an annotation handler has to be registered, and such handler provides the drawing. In my case I don't need any custom drawing. I just need to mark somehow the different links, assigning a type to each.
    Thanks for sharing your expertise, and helping the PDF format to become more useful and widespread...
    -Ramon

  • Creating custom annotations (Singleton)

    Hi,
    Am bit out date of java so that's why I am posting this;
    Actually I want to write my custom annotation of Singleton like,
    *@Singleton*
    Class Spooler {
    so now when this annotation is applied on any class will become a singleton by automatically providing the Spooler::getInstence() method (donno may be at runtime or compiletime)
    and if user tries to declare the public constructor then there should be a compile time error that @Singleton is applied so the constructor should not be public.
    Am I asking a correct thing regarding the annotations or am already lost due to being outdate
    thanks in advance
    Edited by: user10657941 on Jun 15, 2011 12:18 AM

    What would be the advantage over using the simpler enum singleton?
    enum Spooler {
        INSTANCE;
    }An enum type automatically ensures that only the instances listed are created.

  • I am planning to create custom defined  DSO Object & Info cube

    Hi ,
                     i am planning to create custom defined  DSO Object & Info cube.what ratio i can calculate what is the keyfields & what are the data fields in DSO.How can i calculate.
                     2. how can i create  suitable dimensions, suitable characterstics  for dimensions.what ratio i can decide.
    Thanks,
    chandu.

    Hi Diego Garu,
                               Thanks for your fast response.i
    VBELN     VBAP     2LIS_11_VAITM                                              0DOC_NUMBER
    POSNR     VBAP     2LIS_11_VAITM                                                0S_ORD_ITEM
    KUNNR     VBAK     2LIS_11_VAHDR                                                 0SOLD_TO
    VBELN     VBRP     2LIS_13_VDITM                                                    0BILL_NUM
    FKDAT     VBRK     2LIS_13_VDHDR                                                 0BILL_DATE
    INCO1     VBRK     2LIS_13_VDHDR(INCO1FieldNot Available in Data Source)     0INCOTERMS
    ZTERM     VBRK     2LIS_13_VDHDR(Payment terms field Not Available in Data Source)                                                                                0UCPYTERMS
    NETWR     VBRP     2LIS_13_VDITM                                                           0NETVAL_INV.
                                           here data is coming from the multible tables.that why i am planning to create custom defined data source based on view. here how can i calucate dso is suitable or cube is suitable.
    suppose dso is suitable how can i decide which on is the data field and which one is the key field.
                                        how can i decide how many dimensions are needed here.and which chara are suitable for that dimensions.
    Thanks ,
    chandu.

  • How do I create multiple objects during runtime?

    I don't know how to create multiple objects during runtime, here's my problem:
    I get a String as input. Then I create an object called newobject. I put the object in a hashtable with the above string as key.
    Then comes the problem, in order to create a new object, I have to rerun the same class, which uses the same name (newobject) to create a 2nd object. Now my hashtable doesn't reference to my 1st object anymore...
    Is there anyway I can fill up the hashtable with different objects, and make each key point to each object it was supposed to?
    For those who want to see a bit of the program:
    public class PlayBalloon{
    public Hashtable ht = new Hashtable();
    for(){
    Balloon pB = newBalloon;
    newBalloon=new Balloon(pB);
    ht.put("Some input from user", newBalloon);
    for(){
    ht.get(s).draw;<= s=string, draw=own meth. in Balloon
    }

    I think i can see the problem that you are having. You have, in effect, duplicate keys in your hashtable - ie, two strings used as keys with the same name.
    The way that a hashtable works is as follows...
    When you ask for a value that is mapped to a key it will go through the table and return the first occurence it finds of the key you asked for. It does this by using the equals() method of whatever object the key is (in your case it is a String).
    If you cant use different Strings for your keys in your hashtable then i would consider writing an ObjectNameKey class which contains the String value that you are trying to put in the hashtable and an occurrence number/index or something to make it unique. Remember to override the equals method in your ObjectNameKey object or else the hash lookup will not work. For example
    class ObjectNameKey {
        private String name;
        private int occurence;
        public ObjectNameKey(String name, int occ) {
            this.name = name;
            this.occurence = occ;
        public String getName() {
            return name;
        public String getOccur() {
            return occurence;
        public boolean equals(Object o) {
            if (!(o instanceof ObjectNameKey)) {
                return false;
            ObjectNameKey onk = (ObjectNameKey)o;
            if (onk.getName().equals(name) && onk.getOccur() == occurence) return true;
            return false;

  • How to create a text object at runtime?

    Hi,
    I am using crystal reports for visual studio 2010 and using c# to programming.
    I need to create  a text object in a specific section like section 2. and also I need to control the text object's position and text.
    I tried to move a object like:
    reportDocument1.ReportDefinition.Sections[j].ReportObjects<i>.Left = 0x8760;
    but object's position doesn't change at all.
    How can I do these (create a text object and change a object postion)?
    Thanks

    Hi Don,
    Thank you.
    I have downloaded a RAS ( report application Server ) sample.
    The sample uses the Business Objects Enterprise XI release 2. I am using win 7 and crystal reports for vs2010. Can I use this version of crystal reports to create  a text object at runtime? If not, what is the lowest version I have to purchase to achieve what I want?
    Basicly I need following capabilities at runtime:
    1) craete text objects, line objects, image objects.
    2) change text object, line object and image object positions, sizes, values of text object. If can I like to be able to change font as well.
    3) supress objects, sections. 
    4) change section's height

  • Archiving Object - Entry missing in Customizing table for object Z*********

    Hello friends,
    We have created a archiving object in transaction AOBJ. However when i enter this object in SARA, we get this error message.
    "Entry missing in Customizing table for object Z******* "
    I have matched my object with few other archiving objects and things looks similar.
    Have you faced this kind of problem..
    thanks
    ashish

    Hi,
    I checked and i can see entry for ZSCS_TRAFO object in AOBJ.
    But when i enter ZSCS_TRAFO, i get this error :
    Entry missing in Customizing table for object ZSCS_TRAFO
    Message no. BA057
    Diagnosis
    A function cannot be executed due to a missing table entry.
    Procedure
    Please create an entry for the archive object ZSCS_TRAFO with the AOBJ transaction.
    However, a few other Z objects works well.
    thanks
    ashish

  • Authorization Issue with Custom Pending Value Object and Anonymous Users

    Hi,
    I am just converting my demo from version 7.1 to 7.2. I am not doing upgrade. The demo uses a custom pending value object USER_REQUEST. The idea is that new employee goes to Java AS as anonymous user and enters her details and store where she will work. After submitting request there is an approval process using custom entry type USER_REQUEST. If the request is approved then IdM converts USER_REQUEST into MX_PERSON entry. This works nice in 7.1 but I am having problems with replicating this in 7.2. I created new UI task accessible by anonymous that creates new USER_REQUEST entry. I also assigned role idm.anonymous with UME action idm_anonymous to UME built in group Anonymous users.
    My problem is with the field STORE. This field is a reference field to another custom entry type STORE (this entry type will be used in context based assignment). Every new employee must selects a store where she will work. The problem is when user clicks on button "Select". Web dynpro terminates and returns authorization error. I also tested this with entry type MX_ROLE. I added attribute MXREF_MX_ROLE and same issue. So it seems that just assigning UME action idm_anonymous is not enough to list objects from identity store. I found a workaround for this issue. When I assign also UME action idm_authenticated to Anonymous users then it does not dump and I get a pop up window where I can search for store. It does not seem right to assign idm_authenticated to anonymous users.
    Another issue is with display task for entry type USER_REQUEST. I assigned a display task to entry STORE and I set that Anonymous have access to this task in Access control tab. I assigned default value to the field store. So when a user opens page she can see a hyper link to display already assigned store. When user clicks on this hyper link it opens a new pop up window and user must authenticate against Java AS. After successful authentication the display task for entry STORE is displayed. I would assume that anonymous user can display it without authentication.
    So to me it seems like authorization checks have been changed in 7.2 versions and are more strict for anonymous tasks. Hence my question is how can I implement my scenario. Am I missing some configuration or what's the proper solution to my two issues? I don't count assigning idm_authenticated to Anonymous users as a solution. This workaround does not solve my second issue.
    Thanks

    Some of the folks from Trondheim labs check, but rather infrequently.  There's another person who I guess is in consulting that also checks from time to time.
    Sorry I can't help you with your main question...
    Matt

  • Error while reading: 'ungültiges Anmerkungsobjekt' (invalid annotation(al object))

    Dear users,
    I am currently reading and taking notes (highlighting and commentary) on a pdf document.
    Since last week, whenever I open it and reach the page where I stopped reading I get an error:
    'ungültiges Anmerkungsobjekt' (=invalid annotation(al object)). When I click on ok it reappears several times.
    As soon as I scroll it starts over. Other pdf documents works properly.
    What can I do?
    Thanks a lot
    Cristy

    On 3/24/2015 same problems, after Adobe Acrobat 9 pro. crashed while I added text boxes.. When I opened Adobe again, Yes to open the last file which didn't save correctly, then "Invalid Annotation Object" errors on my .pdf file of 96 pages
    - first, I had to acknowledge/click the OK button until all " invalid annotation objects" error pop-up windows are gone
    (for my file with 96 pages, i had to hit the OK button more than hundreds times - need patience)
    - then found out (later) that what I did turn out to be the same steps as following post by davidsdomingo in adobe.forums
    davidsdomingo May 28, 2009 1:39 PM (in response to (Holger_Wulf))
    Here is a technique for identifying all the pages that have invalid annotation objects on them:
    1. Document > Extract Pages ...
    •Select the checkbox for "Extract Pages As Separate Files"
    •Set the destination to a 'dedicated' folder that won't contain any other files -- that way, you can simply delete the folder when this process is done.
    •Click OK.
    2. During the extraction, click OK in all the message boxes that appear.
    3. After the extraction, look in the destination folder to see which pages are missing. Those are the pages that have invalid annotation objects.
    From this point you can try to delete the objects, or simply delete and replace the pages, or implement a different solution. Hope this helps someone.
    - after extract the 96-pages file into individual files into a dedicated folder, only 95 got extracted and page 1 was not/can not be extracted.
    - I then combined the 95 good extracted pages into a new file name .pdf
    - then inserted a good page 1 without error (from the file that was saved previous day, prior to all the changes I made on the corrupted file), re work on page 1
    - delete the bad file.
    Hope this helps someone.

  • Object with runtime number '0' not defined

    Hello,
    We have a problem in one step of the workflow we created for sales orders.
    The following are the errors:
    EXECUTE_METHOD_OBJECT_SYNC -> Object with runtime number '0' not defined
    EXECUTE_METHOD_BOR -> Object with runtime number '0' not defined
    EXECUTE_METHOD_BOR -> Object with runtime number '0' not defined
    Object with runtime number '0' not defined
    Message no. OL808
    We have already seen all the binds and correct.
    Thanks!
    Ariel Prebianca

    Associated message no with message 'Object with runtime number '0' not defined' is OL 808.
    Check Note 1322173 - Wrong error msg raised in BP_JOB_READ of interrupt process. It may not directly solve the issue but it will help you show correct message.

  • Simple example of a custom annotation    for log

    Please help me write me my custom annotations. I like to use them to provide log ,security etc . I did not find articles where I can write my annotation to change the behaviour. Suppoe I decare annotation on a method , I want jvm to call code in my annotation where I can control the behaviour of the method similar to aop stuff ,
    here is what i need
    MyClass {
      @MyCustomAnnotation
       void myMethod(){
    }now I want MyCustomAnnotation to log that this method is begin called can I do this ?

    I can think of only one way to do something like this, and it's messy:
    Let's say your code looks like this:
    public class MyClass
        @MyLogging
        public void myMethod(String arg)
    }Have your @MyLogging annotation processing generate a new Class source that extends your original class and overrides the methods that you've annotated with code that looks something like this:
    public class MyClassGenerated extends MyClass
       Log log = ... // create a logger
        @Override
        public void myMethod(String arg)
            log.info("myMethod called");
            super.myMethod(arg);
    }Now you'll have to change your code to use MyClassGenerated instead of MyClass, which presents its own problems... you may be able to add in some kind of factory mechanism or something to make that work easier.

  • Custom change document object

    I want to trigger a new change object behind the standard tcode . In exit I need to call Y_DEBI_WRITE_DOCUMENT  to update my Y_DEBI custom change object . But when I am trying to update Generation prg on SCDO it asks a Table_frame func module ..
    Is the custom change document objects are designed for custom tables ?.
    Edited by: carlos eduardo on Aug 6, 2008 7:50 AM

    Yes Carlos,
    It is desined for Custom Tables.
    For more information you can look into the following link:
    http://www.sapdevelopment.co.uk/tips/changedoc/cdhome.htm
    Regards,
    Rizwana

  • Custom Made Authorization Object ZPLANT

    Hi
    We have custome made auth objects; zplant, zcountry, zsalesrg etc. We are getting problems with one of the report we created; based on a MP. When user access the report, some of them getthe error that "Warning you do not have authorization to read object ZPLANT Authorization at plant".
    The user has access to 4 plants and can access other reports based on the Infocubes that is used in the MP. Also some of the user gets warning for ZSALESORG etc..
    We are getting this error only for the newly created report; Have any of you faces such type of problem? If yes then can you advice me how to resolve it?
    Thanks in advance
    Ishi

    Hi there again,
    Sorry my mistake, it is S_RS_ICUBE instead of S_RS_CUBE. In that authorization you can specify the InfoCubes or MultiCubes alloweded to display. Your multiprovider might be included or not in that object.
    S_RS_COMP  and S_RS_COMP1 is for BEx.
    You can include this:
    S_RS_COMP:
    Activity: 03, 16 (display and execute)
    InfoArea: * (all of them, or sepcify an InfoArea where the InfoProviders which contains the queries are)
    InfoCube: * (all of them, or specify the InfoProviders which have the queries you want the users to run)
    Name (ID) of a reporting compo: * (all of them)
    Type of a reporting component: CKF, QVW, REP, RKF, STR, VAR
    S_RS_COMP1:
    Activity: 03, 16 (display and execute)
    Name (ID) of a reporting compo: * (all of them)
    Type of a reporting component: * (all of them)
    Owner (Person Responsible) for: * (all of them)
    You can also use transaction RSSMQ to execute a query with another user and analise the authorizations of that user.
    Diogo.

Maybe you are looking for

  • Fifth Generation iPod won't update music

    My new fifth generation 30gb iPod refuses to be updated. It worked fine until I transfered a few photos onto it and now unless I have the "synchronise photos from" check box checked, I no longer have the option to update. When I have the box checked

  • "Payment Order Only" In APP

    Hi Frends, when we are configuring the APP,there will be one filed Called "PAYMENT ORDER ONLY" ,what is the purpose of the filed?

  • "nu" Font [solved]

    A while back there was a topic that had a nice little list of fonts that people liked/used for terminal work.  There was a font in there that I used to have on another system called "nu".  I cannot for the life of me find that font now.  Can someone

  • No luck installing Presenter- been more than 8 hours!

    I installed Adobe Acrobat 9 Pro Extended and it has Adobe Presenter included in it. But when I open PowerPoint files there's no presenter tab. I thought I need have to install Presenter separately. So, from the installation disk I clicked on "Install

  • Truncated BW Bookmarks

    I am a BW Administrator for a large university.   We are currently running SAP NetWeaver BI 7.0 SP16.  We have many users who like to create and run bookmarks for BW reports.  Recently a problem surfaced in that, on some specific computers, any URL l