Java Reflection Performance (Suggestion...?)
So: I have a program in which I would, for example, like to have a reference to the Method object which represents the method Integer.parseInt(String). Is there any better way to get my hands on the Method object than to request the method from the Class object? In some cases, the method I am requesting is a little harder to get my hands on than that.
In Java, you can Integer.class to get the Class object representing the Integer class. I don't suppose there's anything like that for the method of a class... such as: Integer.parseInt.method(new Class[]{String.class});
Does anyone have any suggestions? It seems to me that these sorts of things should be resolved at compile-time and not at runtime via String comparison.
Thanks! I look forward to responses!
... as far as I know, no.
The only way to get a Method object is to search for it in the class with Class.getDeclaredMethod("xxy", args[]) or however that looks, but yes, you can't instantiate the Method class so it seems like the only solution.
Similar Messages
-
Performance difference between java.beans.Expression and Java Reflection
What is the Performance difference between using java.beans.Expression class and Java Reflection classes like Class,Method ??
negligible
-
Help need regarding Java Reflection
I need help in programming the following:
I have to generate a test Harness for OOP.This program that automatically tests
classes by instantiating them, selecting methods of these instantiated objects randomly or
using some criteria, invoking them, and using the returned values as input parameters to
invoke other methods. I have to use Java Reflection for this and methods must be of generic type!
For this
I have to generate a tree of functions(say 2 or 3).The functions could be say:int f(int){} and int g(int){}. or Int f(String), String g(float),Float h(int)..I have to create a tree of these function set and traverse them in BFS or DFS and generate combinations of these functions keeping some upper bound for the number of functions genrated(10) and size of combinations of functions(say 5).The output of one function should be the input to other function(so recursive).If any combination failed,then record(or throw exception).This all should be done using java reflection.The input can be provided though annotations or input file.This file can result in recording even the output for each function. I have tried using Junit for testing methods.My code with is following:I have two classes ClassUnderTestTests(which tests the methods of ClassUnderTest) and ClassUnderTest shown below
//Test Harness class
public class ClassUnderTestTests {
Field[] fields;
Method[] methods;
Method minVal;
Method maxVal;
Method setVal1;
Method setVal2;
Method getVal1;
Method getVal2;
Class<?> cut;
ClassUnderTest<Integer> obj1;
ClassUnderTest<String> obj2;
@Before public void setUp(){
try {
cut = Class.forName("com.the.ClassUnderTest");
fields=cut.getDeclaredFields();
methods=cut.getDeclaredMethods();
print("Name of the CUT class >>"+ cut.getName());
print("List of fields >>"+ getFieldNames(fields));
print("List of Methods >>"+ getMethodNames(methods));
//creating method objects for the methods declared in the class
minVal=cut.getDeclaredMethod("minValue");
minVal.setAccessible(true);
maxVal=cut.getDeclaredMethod("maxValue");
maxVal.setAccessible(true);
setVal1=cut.getDeclaredMethod("setVal1", Comparable.class);
setVal1.setAccessible(true);
setVal2 = cut.getDeclaredMethod("setVal2", Comparable.class);
setVal2.setAccessible(true);
getVal1=cut.getDeclaredMethod("getVal1");
getVal1.setAccessible(true);
getVal2 = cut.getDeclaredMethod("getVal2");
getVal2.setAccessible(true);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
@Test public void cutIntegertest(){
//instantiating the class using the argument constructor for Object 1
Constructor<?> constr1;
assertNotNull(cut);
try {
constr1 = cut.getDeclaredConstructor(Comparable.class,Comparable.class);
obj1=(ClassUnderTest<Integer>)constr1.newInstance(Integer.valueOf(102),Integer.valueOf(20));
assertNotNull(obj1);
print("The object of CUT class instantiated with Integer Type");
// invoking methods on Object1
assertEquals(minVal.invoke(obj1),20);
//Object x = minVal.invoke(obj1);
print("tested successfully the min of two integers passed");
assertEquals(maxVal.invoke(obj1),102);
// maxVal.invoke(obj2);
//print();
print("tested successfully the max of two integer values" );
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
@Test public void cutStringTest(){
assertNotNull(cut);
Constructor<?> constr2;
try {
constr2 = cut.getDeclaredConstructor(Comparable.class,Comparable.class);
obj2=(ClassUnderTest<String>)constr2.newInstance(String.valueOf(obj1.maxValue().toString()),obj2.minValue().toString());
//obj2=(ClassUnderTest<String>) cut.newInstance();
assertNotNull(obj2);
//assertNotNull("obj1 is not null",obj1);
//print(obj1.maxValue().toString());
print("Object 2 instantiated as String type ");
print("setting values on object2 of type string from values of obj1 of type Integer by using toSting()");
setVal1.invoke(obj2, obj1.maxValue().toString());
setVal2.invoke(obj2, obj1.minValue().toString());//obj2.setVal2(obj1.minValue()
assertEquals(getVal1.invoke(obj2),maxVal.invoke(obj1).toString());
assertEquals(getVal2.invoke(obj2),minVal.invoke(obj1).toString());
print("validating the Assert Equals set from object 1 after conversion to String");
print("MinValue for Object2 when Integer treated as String>>> "+minVal.invoke(obj2));
print("MaxValue for Object2 when Integer treated as String>>> "+maxVal.invoke(obj2));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
//obj2.setVal1(obj1.maxValue()
private static void print(String str){
System.out.println(str);
private String getMethodNames(Method[] methods) {
StringBuffer sb= new StringBuffer();
for(Method method: methods){
sb.append(method.getName()+ " ");
return sb.toString();
private String getFieldNames(Field[] fields) {
StringBuffer sb= new StringBuffer();
for(Field field: fields){
sb.append(field.getName()+ " ");
return sb.toString();
//ClassUnderTest
public class ClassUnderTest <T extends Comparable<T>>{
//Fields
private T val1;
private T val2;
ClassUnderTest(){}
public ClassUnderTest(T val1, T val2){
this.val1=val1;
this.val2=val2;
* @return the val1
public T getVal1() {
return val1;
* @param val1 the val1 to set
public void setVal1(T val1) {
this.val1 = val1;
* @return the val2
public T getVal2() {
return val2;
* @param val2 the val2 to set
public void setVal2(T val2) {
this.val2 = val2;
public T maxValue(){
T max=null;
if(val1.compareTo(val2) >= 0){
max= val1;
}else {
max= val2;
return max;
public T minValue(){
T min=null;
if(val1.compareTo(val2) < 0){
min= val1;
}else {
min= val2;
return min;
This code throws Null Pointer Exception if CutStringtest function(I think on calling obj1 in tht function) Please suggest!Well, I can't help you specifically since I'm not into reflection too much, but here are some ideas:
* Either learn how to set breakpoints and single step through your code, or pepper your code with a lot more meaningful System.out.println() statements.
* Come up with simple test cases, pass them first, then progressively more complex test cases, until you test all possible situations. Try to get each test case to test only a single concept and not multiple concepts at the same time. If your code is broken on more than one concept, you will not be able to isolate each concept by itself to fix it without separating it.
* Consider refactoring your code so each sub-module accomplishes one task in isolation and verify that module can handle each possible situation that its asked to perform.
* The exception usually tells you what line in your code threw the exception. Look for a line in the exception printout that has the name of your package or class in it. -
Java reflection - any disadvantages
1. Are there any disadvantages in using java reflection api (too much)?
2. How do obfuscators deal with reflection based applications?
Thanks
SantoshSorry, i wanted to know how the code
Object obj = new MyClass();
is different from
Class clazz = Class.forName("MyClass");
Object obj = clazz.newInstance();
at the byte-code level.
That is, in both the cases the classloader has to
search for MyClass and invoke the constructor. Hope I
am clear :)I don't think there is any difference as far as performance is concerned between the above mentioned methods for instantiating the object of MyClass.
But here is what is generally said about using reflection(u can find it on google):
===============================================================
Don?t overuse the Reflection API. Programs that use it are more difficult to understand and maintain. In addition, accessing fields and calling methods through the Reflection API is slower than using them in the ?normal? way, so use reflection only when it is really necessary.
===============================================================
We too had concerns about reflection's performance, but as long as you cache the lookups, reflection is very fast. What is slow is doing things like looking up a method on a class or looking up an instance member. We do all these lookups once and then cache the results.
===============================================================
Why is it slow as stated above? - Maybe because flexibility always comes at a price !!! Maybe the internal implementation of the call sequence by the JVMs is such that it cannot be implemented any faster... -
Can Java reflect not only .Class file
Hi' i'm newbie in this topic, i'm really appreciate if somebody can help me..cos i'm really stuck in here...
My Problems are :
1. i want to ask about this, can Java reflect from .java file?
2. i'm using Eclipse IDE, i'm really interesting about how JTree or Package Explorer in Eclipse can always displaying update information about class structure? but .java files not compiled, how can? if Eclipse using reflection, .java files must be compiled first, correct me if i'm wrong?
The fact is Eclipse don't have to compiled .java files to get the update information about class structure and displaying in JTree or package Explorer...how implement like this?
what i mean like this :
ex : if i type int x = 100; (not only int, it could be anything else..) at the working files, JTree or Package Explorer in Eclipse can always update the informasion about class structure, but .java files not compiled..
i hope my question are easy to understand, i really need some help..
Thanks a lot..hey, thanks for the answers, but i would like to ask :
1) Eclipse performs background compilation of the Java sources, then performs reflection on those temporary classes++ if i'm using this way, how about the performance? seems that it will be compiled all the time right?
2) Eclipse has access to the results of the Java source code parser, and can extract the information from the java syntax parser, before it gets to the compilation stage.++ how to implement this? what do you mean about java syntax parser?
do you know where i can find any article about this?
thanks a lot again... -
Java Reflection and dynamic class loading
I am trying to load my classes 'dynamically' using java reflection, which is a feature absolutely necessary for my webapp. I could not get this to work as of yet. Could someone please give me a piece of sample code that would do the following :
- return the value (String) of known method y from class x
- class x is only known at runtime (from the query-string in this case)
- method y is known
Thanks in advance.
cheers,
Tom
PS: Please do not give me any links to tutorials/articles that do not do the EXACT thing that I asked for. Thank you.tried it, but it always gives me a MethodNotFoundException, because its trying to find my class in java.lang.String for some reason...
heres part of the code (its an altered version of the code given in the invoke tutorial):
public String getMethodReturnValue(String methodName, String className) {
String result = null;
Class theModuleClass = String.class;
Class[] parameterTypes = new Class[] {};
Method concatMethod;
//Object[] arguments = new Object[] {parameters};
try {
concatMethod = theModuleClass.getMethod(methodName, null);
result = (String) concatMethod.invoke(createObject(className), parameterTypes);
} catch (NoSuchMethodException e) {
result = e.toString();
} catch (IllegalAccessException e) {
result = e.toString();
} catch (InvocationTargetException e) {
result = e.toString();
return result;
private Object createObject (String className) {
Object object = null;
try {
Class classDefinition = Class.forName(className);
object = classDefinition.newInstance();
} catch (Exception e) {}
return object;
Thanks for any help!
-Tom -
Hi Every1....i have a problem with java reflection n hope some1 will be able to resolve this me.
I am getting the name of the child class as a string argument.
eg String classname = this.getattributes().get("classname");
I need to dynamically create the object of this instance using the classname and call a specific method...i know the name of the base class but the base class doesnt have the method i need....i m not allowed to redesign the base class...
plz helpbut the problem is getting the method nameIf you don't have the method name what exactly is the plan? You've gotta have something ...
.....i have the object of base class with meActually the object is an instance of the derived class ...
....and the method i
need is in the child class.....so how do i invoke the
method???Sigh. You can lead a horse to water but you can't make him drink. See
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html#invoke(java.lang.Object,%20java.lang.Object...) -
Code generation through Java Reflection
Hi
I am after some clarification about the possibility of mapping of method outputs to other method inputs, using java reflection.
The java objects are described in an XML based language (called DAML) as follows
<java:Method rdf:ID="meth1" java:priority="1">
<java:methodName>buildQuery</java:methodName>
<java:parentClass>afsw.query.QueryBuilder</java:parentClass>
<java:methodParameters rdf:parseType="daml:collection">
<java:Parameter>
<java:inORout>input</java:inORout>
<java:type>java.util.Hashtable</java:type>
</java:Parameter>
</java:methodParameters>
</java:Method>
and I want to map them back to method calls and instantiations, so to be able to generate code on the fly. I need to know if its is possible to pass the output of a method such as getQuery() which in this case is a Document to the input of constructor MsgModule as in the following example:
Document queryDoc =qc.getQuery();
MsgModule mg= new MsgModule(queryDoc);
regards
CharlieThis is possible. What you need to do in the 'new' instance case is to find the best constructor. So let's say you have Class clazz, the class you want to create a new instance of, and Class[] params, an array of objects to pass in the constructor. Using the Class api you can do:
Constructor constructor = clazz.getConstructor(params);The getConstructor method will only return an exact match. Let's say one of the parameters was a subclass of an class that is allowable in the constructor. You can get all the constructors via clazz.getConstructors() and get all the parameters types via Constructor.getParameterTypes() and check to see if the params you passed in are compatible. You can use Class.isAssignableFrom() to help resolve this. Once you find the constructor, use Constructor.newInstance(params) to create the new instance. Hope this helps. -
Java reflection and parameter's names
hi, I have to extract from a method of a given class all types and names of the parameters, i've tryed to use java reflection function:
Method[] metodo = temp.getDeclaredMethods();
for (int i = 0; i < metodo.length; i++) System.out.println(metodo.toString());
and the output is:
public void DinamicLoad.function1.method1()
public void DinamicLoad.function1.method2(java.lang.String)the function extract only the parameter's type, not his nameProbabily all the "dozens, hundreds, thousands of
other people who use reflection" knows very well
classes that they use.
Imagine to produce a class from a wsdl file, how can
you know the content?
How can you pass parameters if you know only the type
and not the MEANING?When building classes from XML it's rare to use the constructor to convey the attributes, far more often each attribute is set independantly using a single argument setter with a signature like:
public void setMyAttribute(String value) {Hence attribute names (e.g. myAttribute) are normally compared against method names, not parameter names.
If constructors are to be used then parameters will be supplied in order. -
Java reflection (interesting question)
hi folks,
class A {
void foo() {
Class B overrides method foo() in A
class B extends A {
void foo() {
Now i create a object of class B and assign to A
A aref = new B();
aref.foo() will call method foo()of class B. //polymorphism
Using reflection, is it possible to call method foo() of class A using the handle aref.
thanks
venkathi bondvenky,
What abt the answer for my original question. How to
access the base class methods using the handle for
child class object using reflection ?as far as i know, this isn't possible - your next question is probably going to be "why". It certainly seems slightly surprising that you can't do this, but you can access private methods. Unless you consider the latter a weaker way of breaking encapsulation (!?).
what was the sun's purpose behind allowing access to
the private methods of an object using Java
Reflection? good question.. its very useful but on the other hand i can't think of a time i've used it that couldn't be classed as a hack.
Is it not a security threat to java security model?it doesn't break anything - ie its not a security loophole. It links in with your question above though - would it have been possible/useful to not allow it period?
sorry for the vague answers :(
asjf -
Hi experts!!
Any performance Suggestions for following codes:
form display_data .
DATA: i_npdreq TYPE TABLE OF znpdreq,
w_npdreq TYPE znpdreq.
data: i_link type table of crmd_link,
w_link type crmd_link.
data: i_partner type table of CRMD_PARTNER,
w_partner type CRMD_PARTNER.
data: i_but000 type table of but000,
w_but000 type but000.
data: i_orderadm_i type table of crmd_orderadm_i,
w_orderadm_i type crmd_orderadm_i.
select * into table i_npdreq
from znpdreq
where object_id = w_orderadm_h-object_id
and process_type = 'ZNPD'.
read table i_npdreq into w_npdreq
with key process_type = 'ZNPD'.
i_final-guid = w_orderadm_h-guid.
i_final-object_type = w_orderadm_h-object_type.
i_final-ZPRODNO = w_npdreq-ZPRODNO.
i_final-ZPRODMS = w_npdreq-ZPRODMS.
i_final-ZREQNO = w_npdreq-zreqno.
i_final-ZPRODNA = w_npdreq-ZPRODNA.
i_final-description = w_orderadm_h-description.
append i_final.
select * into table i_orderadm_i from crmd_orderadm_i
where header = w_orderadm_h-guid.
read table i_orderadm_i into w_orderadm_i
with key header = w_orderadm_h-guid.
loop at i_final where guid = w_orderadm_i-header.
i_final-ORDERED_PROD = w_orderadm_i-ORDERED_PROD.
i_final-DESCRIPTION_UC = w_orderadm_i-description_uc.
modify i_final.
endloop." i_final _orderadm_i
select * into table i_link from crmd_link
where GUID_HI = w_orderadm_h-guid.
loop at i_link into w_link.
loop at i_final where guid = w_link-guid_hi.
i_final-guid_hi = w_link-guid_hi.
i_final-guid_set = w_link-guid_set.
modify i_final.
endloop. "i_final for crmd_link
select * into table i_partner from crmd_partner
where guid = w_link-GUID_SET
and partner_fct = '00000021'.
read table i_partner into w_partner
with key partner_fct = '00000021'.
loop at i_final where guid_Set = w_partner-GUID.
* *i_final-partner = w_partner-partner.
i_final-PARTNER_GUID = w_partner-PARTNER_GUID.
i_final-partner_no = w_partner-partner_no.
modify i_final.
endloop. "i_final for partner.
loop at i_partner into w_partner.
select * into table i_but000 from BUT000
where PARTNER_GUID = w_partner-PARTNER_NO.
read table i_but000 into w_but000
with key PARTNER_GUID = w_partner-PARTNER_NO.
loop at i_final where partner_no = w_but000-partner_guid.
i_final-partner = w_but000-partner.
i_final-mc_name1 = w_but000-mc_name1.
i_final-MC_NAME2 = w_but000-MC_NAME2.
modify i_final.
endloop.
endloop. "i_partner
endloop. "i_link
break-point."testing
break-point.
endform. " display_data<FUNCTION-POOL ZBAPI_OPPORTUNITY_FOR_SEARCH_HELP. "MESSAGE-ID ..
types: begin of order_h,
GUID type crmd_orderadm_h-guid,
OBJECT_ID type crmd_orderadm_h-object_id,
PROCESS_TYPE type crmd_orderadm_h-process_type,
DESCRIPTION type crmd_orderadm_h-description,
object_type type crmd_orderadm_h-object_type,
end of order_h.
* parent header internal table with workarea
data: i_orderadm_h type HASHED TABLE OF order_h
with UNIQUE KEY OBJECT_ID PROCESS_TYPE,
object_id
w_orderadm_h type order_h.
types: begin of order_i,
GUID type crmd_orderadm_i-guid,
header type crmd_orderadm_i-header,
PRODUCT TYPE crmd_orderadm_i-PRODUCT,
ORDERED_PROD type crmd_orderadm_i-ordered_prod,
description_uc type crmd_orderadm_i-description_uc,
end of order_i.
data: i_orderadm_i type HASHED TABLE OF order_i
with UNIQUE KEY guid header,
object_id
w_orderadm_i type order_i.
* child header internal table with workarea
DATA: i2_orderadm_h TYPE HASHED TABLE OF order_h
with UNIQUE key guid OBJECT_ID,
w2_orderadm_h TYPE order_h.
*For Status Text
types: begin of t_text,
STSMA type TJ30T-STSMA,
ESTAT type tj30t-ESTAT,
SPRAS type tj30t-spras,
TXT30 type tj30t-TXT30,
end of t_text.
data: i_TJ30T type HASHED TABLE OF t_Text
with UNIQUE KEY stsma estat,
w_tj30t type t_text.
parent internal table for function module1 (crm_order_read)
DATA: lt_header_guid TYPE crmt_object_guid_tab,
lv_header_guid TYPE string,
lt_subject TYPE crmt_subject_wrkt,
it_subject LIKE LINE OF lt_subject.
*child internal table for function module2 (crm_order_read)
DATA: lt_header_guid2 TYPE crmt_object_guid_tab,
lv_header_guid2 TYPE crmt_object_guid_tab,
iv_header_guid2 TYPE string,
iv_header_guid TYPE crmt_object_guid.
*parent doc_flow internal table and work area
DATA: im_doc_flow TYPE crmt_doc_flow_wrkt,
w_doc_flow TYPE crmt_doc_flow_wrk.
*parent status internal table and work area
DATA: im_status TYPE crmt_status_wrkt,
w_status TYPE crmt_status_wrk.
*child doc_flow internal table and work area
DATA: im2_doc_flow TYPE crmt_doc_flow_wrkt,
w2_doc_flow TYPE crmt_doc_flow_wrk.
*child status internal table and work area
DATA: im2_status TYPE crmt_status_wrkt,
w2_status TYPE crmt_status_wrk.
types: begin of t_npdreq,
OBJECT_ID type znpdreq-OBJECT_ID,
process_type TYPE znpdreq-PROCESS_TYPE,
ZPRODNO type znpdreq-zprodno,
ZPRODMS type znpdreq-ZPRODMS,
ZREQNO type znpdreq-zreqno,
ZPRODNA type znpdreq-zprodna,
end of t_npdreq.
data: i_npdreq type HASHED TABLE OF t_npdreq
with UNIQUE KEY ZREQNO object_id,
w_npdreq type t_npdreq.
TYPES: begin of t_link,
GUID_HI type crmd_link-guid_hi,
GUID_SET type crmd_link-guid_set,
end of t_link.
data: i_link type HASHED TABLE OF t_link
with UNIQUE KEY guid_HI guid_set,
w_link type t_link.
types: begin of t_partner,
guid type crmd_partner-guid,
PARTNER_GUID type CRMD_PARTNER-partner_guid,
PARTNER_FCT type CRMD_PARTNER-partner_fct,
PARTNER_NO type crmd_partner-partner_no,
end of t_partner.
DATA: i_partner type HASHED TABLE OF t_partner
with UNIQUE key partner_fct partner_no,
w_partner type t_partner.
types: begin of t_but000,
PARTNER type but000-partner,
MC_NAME1 type but000-mc_name1,
MC_NAME2 type but000-mc_name2,
PARTNER_GUID type but000-partner_guid,
end of t_but000.
DATA: i_but000 type HASHED TABLE OF t_but000
with UNIQUE key PARTNER partner_guid,
w_but000 type t_but000.
DATA: flag(1) TYPE c.
*internal table for search_help
DATA: BEGIN OF i_final OCCURS 0,
guid TYPE crmd_orderadm_h-guid,
guid_hi TYPE crmd_link-guid_hi,
guid_set TYPE crmd_link-guid_set,
partner_guid TYPE crmd_partner-partner_guid,
partner_no TYPE crmd_partner-partner_no,
partner type crmd_partner-partner,
object_type TYPE crmd_orderadm_h-object_id,
zprodno TYPE znpdreq-zprodno,
zprodms TYPE znpdreq-zprodms,
zreqno TYPE znpdreq-zreqno,
zprodna TYPE znpdreq-zprodna,
partner TYPE but000-partner,
description TYPE crmd_orderadm_h-description,
mc_name1 TYPE but000-mc_name1,
mc_name2 TYPE but000-mc_name2,
ordered_prod TYPE crmd_orderadm_i-ordered_prod,
description_uc TYPE crmd_orderadm_i-description_uc,
END OF i_final.
select GUID
OBJECT_ID
PROCESS_TYPE
DESCRIPTION
object_type
into table i_orderadm_h
from crmd_orderadm_h
WHERE process_type EQ 'ZNPD'.
where object_id = '2001200081'.
*COLLECTING PARENT DATA
LOOP AT i_orderadm_h INTO w_orderadm_h where PROCESS_TYPE = 'ZNPD'.
lv_header_guid = w_orderadm_h-guid.
'47B1161F696F009EE10080005A000954'.
iv_header_guid = lv_header_guid.
INSERT iv_header_guid INTO TABLE lt_header_guid.
CALL FUNCTION 'CRM_ORDER_READ'
EXPORTING
it_header_guid = lt_header_guid
IMPORTING
et_status = im_status
et_doc_flow = im_doc_flow.
READ TABLE im_status INTO w_status
WITH KEY status = 'ZGGLOPPT'.
LOOP AT im_doc_flow INTO w_doc_flow.
*Retriving child DATA
select GUID
OBJECT_ID
PROCESS_TYPE
DESCRIPTION
object_type
into table i2_orderadm_h
from crmd_orderadm_h
where guid = w_doc_flow-objkey_b.
LOOP AT i2_orderadm_h INTO w2_orderadm_h WHERE process_type = 'ZPCO'.
INSERT w2_orderadm_h-guid INTO TABLE lv_header_guid2.
BREAK-POINT.
LOOP AT im_doc_flow INTO w_doc_flow.
CALL FUNCTION 'CRM_ORDER_READ'
EXPORTING
it_header_guid = lv_header_guid2
IMPORTING
et_status = im2_status
et_doc_flow = im2_doc_flow.
READ TABLE im2_status INTO w2_status
WITH KEY user_stat_proc = 'ZGGLCRM'.
txt30 = 'COMPLETED'.
PERFORM display_data.
delete ADJACENT DUPLICATES FROM i_final.
it_output[] = I_FINAL[].
ENDLOOP.
ENDLOOP. "i2_orderadm_h
endloop.
endloop.
ENDFUNCTION.
form display_data .
DATA: i_but000 TYPE TABLE OF but000,
w_but000 TYPE but000.
DATA: i_orderadm_i TYPE TABLE OF crmd_orderadm_i,
w_orderadm_i TYPE crmd_orderadm_i.
SELECT OBJECT_ID
process_type
ZPRODNO
ZPRODMS
ZREQNO
ZPRODNA INTO TABLE i_npdreq
FROM znpdreq
WHERE object_id = w_orderadm_h-object_id
AND process_type = 'ZNPD'.
READ TABLE i_npdreq INTO w_npdreq
WITH KEY process_type = 'ZNPD'.
i_final-guid = w_orderadm_h-guid.
i_final-object_type = w_orderadm_h-object_type.
i_final-zprodno = w_npdreq-zprodno.
i_final-zprodms = w_npdreq-zprodms.
i_final-zreqno = w_npdreq-zreqno.
i_final-zprodna = w_npdreq-zprodna.
i_final-description = w_orderadm_h-description.
APPEND i_final.
SELECT GUID
header
PRODUCT
ORDERED_PROD
description_uc
INTO TABLE i_orderadm_i FROM crmd_orderadm_i
WHERE header = w_orderadm_h-guid.
READ TABLE i_orderadm_i INTO w_orderadm_i
WITH KEY header = w_orderadm_h-guid.
LOOP AT i_final WHERE guid = w_orderadm_i-header.
i_final-ordered_prod = w_orderadm_i-ordered_prod.
i_final-description_uc = w_orderadm_i-description_uc.
MODIFY i_final.
ENDLOOP." i_final orderadmi
SELECT guid_hi guid_Set INTO TABLE i_link FROM crmd_link
WHERE guid_hi = w_orderadm_h-guid.
LOOP AT i_link INTO w_link.
LOOP AT i_final WHERE guid = w_link-guid_hi.
i_final-guid_hi = w_link-guid_hi.
i_final-guid_set = w_link-guid_set.
MODIFY i_final.
ENDLOOP. "i_final for crmd_link
SELECT guid
PARTNER_GUID
PARTNER_FCT
PARTNER_NO
INTO TABLE i_partner FROM crmd_partner
where guid = w_link-guid_set
AND partner_fct = '00000021'.
READ TABLE i_partner INTO w_partner
WITH KEY partner_fct = '00000021'.
LOOP AT i_final WHERE guid_set = w_partner-guid.
i_final-partner_guid = w_partner-partner_guid.
i_final-partner_no = w_partner-partner_no.
MODIFY i_final.
ENDLOOP. "i_final for partner.
LOOP AT i_partner INTO w_partner.
SELECT PARTNER
MC_NAME1
MC_NAME2
PARTNER_GUID
INTO TABLE i_but000 FROM but000
WHERE partner_guid = w_partner-partner_no.
READ TABLE i_but000 INTO w_but000
WITH KEY partner_guid = w_partner-partner_no.
LOOP AT i_final WHERE partner_no = w_but000-partner_guid.
i_final-partner = w_but000-partner.
i_final-mc_name1 = w_but000-mc_name1.
i_final-mc_name2 = w_but000-mc_name2.
MODIFY i_final.
ENDLOOP.
ENDLOOP. "i_partner
ENDLOOP. "i_link
ENDFORM. " display_data > -
Java reflection and singletons
Using java reflection and singletons .. anyone seen this being used?
I've solved it
I had a singleton but then it turned out i had to use reflection instead, i tried to used reflection on 3 methods but the session value within was null upon the second method call. Relfection was re-creating the Object.
Sorry for wasting your time. -
Java Application Performance Monitoring - J2EE Transaction Monitoring
Hi,
Does SCOM 2012 R2 support J2EE transaction monitoring, ie how application behaves from end users. Apdex scores,response time and throughput , Execution method and SQL queries.I could not find transaction monitoring information in Java MP guide.
Is that Java managment pack supports monitoring only Tomcat and not weblogic,websphere and jboss on Linux servers,
Appreciate help in this
Thanks in advance
BharathHi Bharath,
"Apdex scores,response time and throughput , Execution method and SQL queries."
You're talking about the metrics similar to those which we have after configuring application monitoring in .NET Application Performance Monitoring (AVIcode APM) template, right? If so, this sort of APM profiling for Java apps introduced in SCOM 2012
R2. But it's only for Tomcat5.5+ hosted Web Applications:
http://blogs.technet.com/b/random_happy_dev_thoughts/archive/2014/01/07/system-center-2012-management-pack-for-java-application-performance-monitoring-released.aspx
If you use another application server rather than Tomcat (WebLogic, WebSphere, JBoss), I would recommend you to take a look at BeanSpy instrumentation itself:
http://www.systemcentercentral.com/demystifying-jee-app-performance-monitoring-in-opsmgr-2012-jee-faqs/
Download link:
http://www.microsoft.com/en-us/download/details.aspx?id=29270
This is not AVIcode-like APM (AVIcode-like APM relies on it as a prerequisite), but if you are familiar with MBeans structure, you could configure quite interesting monitoring transactions for your java apps:
http://blogs.inframon.com/post/2012/04/27/WebSphere-monitoring-with-the-JEE-Application-Performance-Monitoring-management-packs.aspx
http://stefanroth.net/2012/04/10/scom-2012-jee-application-availability-monitor-template/
Igor Savchenko, VIAcode Consulting LLC (http://www.viacode.com/) -
Awful Java applet performance -- never mind, being handled in a different thread
Awful Java applet performance -- never mind, being handled in a different thread.
Here's some more info that may be of use ... The Applet is signed and this particular problem only occurs with Safari. It has not been seen as of yet when using Firefox. And it definitey does not occur on Windows platforms with IE or Firefox. It's been observed across multiple versions of the applet and appears to have become an issue around the time of Leopard 10.5.6/Safari 3.2.1. I don't know if it has anything to do with the problem, but the html that starts the applet is dynamically generated from javascript. A user clicks a thumbnail image on a web page, the javascript opens a dojo dialog, and within the div that contains the dialog, another div is inserted containing the html that starts the applet. The applet also does a number of liveconnect calls to call javascript methods. When a "close" button is clicked on the Applet, the inverse occurs. The javascript clears the html that contained the applet. The applet's destroy method is called and there are no apparent memory leaks.
The problem never seems to occur the first time the applet is started. It's always on a subsequent instantiation. Frequently, when it occurs, the applet is only partially painted and I sometimes see paint related calls on the stack trace of the awt thread. -
Questions on Java Reflection in EJB
Hi,
Recently, I use reflection technology on EJB to get/set properties of a bean.
We need it because we need to encapsulate data in a map to transfer data between
presentation layer and business back end(i.e. the so-called value data object).
A bean is packed into a map as following:
The property name of a bean becomes the key in the map, and its value becomes the
corresponding value in the map.
So we have to do two things:
1)Given a bean, convert it to a map;
2)Given a data map, assign the value to a bean
It would be nice if we can implement the two requirements in a base class. So I use
reflection. And succeed to achieve the goal.
But there are two problems occured and I can't understand why.
1)If I use Class.forName() to load the entity bean implementation class(BMP or CMP abstract
schema) I got a ClassNotFoundException. A workaround is to jar the BMP or CMP bean class
and place it on the classpath.
So, I want to know why there is such restriction.
2)For the classes java.lang.reflect.Method, java.lang.reflect.InvocationTargetException
I reference to in bean class, the IDE(I use IntelliJ Idea) give me a
warning: "Use java.lang.reflect.Method are not allowed in EJB". Are the methods really
dangerous in EJB environment?
Can anyone explain me these pluzzles?
Thank you in advance!
BTW, I develop under weblogic 7.0. Now, my program functions well, I just can't understand
the above phenomena.
Regards,
Justine1) You should never directly manipulate the EJB implementation class. That class is for the container. When accessing EJBs (no matter the means), you should use the Home/Remote or Local interfaces - those your client should already have. If what you're doing is actually working for you, I can only say that you're not using EJBs properly and are not getting the actual "bang for the buck" you paid for. And you're damn lucky it hasn't blown bits all over the place...
2) Yes, it is potentially dangerous to be dorking around with reflection on EJBs. When you're using the Home/Remote or Local interfaces, you're actually using an Object that the vendor supplies to perform the actual remote operations. Using reflection could potentially invoke one of the "hidden" vendor methods with extremely unpredictable results - like deleting your entire table.
As for using a map for transferring data, I would strongly recommend against it, especially in this case, because you've not only lost the strong typing you get with ValueObjects, but you have to do a lot of extra work on both "sides" (client and EJB) to make sure all your data is present and/or correct.
Maybe you are looking for
-
How do I connect my G5 1.8 PowerMac to a new 2011 iMac?
I'm planning on purchasing a new mid-year 2011 iMac soon, I'd like to connect my Power Mac G5 1.8 to the iMac; to mount to the new iMac's desktop so that I can use the internal drives on the G5 as backups, and for retrieving files I currently have o
-
2.5'' sata Toshiba Hard disk not detected
Hi everyone, recently I bought a ssd drive for my macbook and formatted my original Toshiba hard disk I bought a box for hdd and when I plug it to usb as external drive it cannot be seen by mavericks.I tried disk utility ,it cannot also see. I tried
-
Unable to get the customer profile in CSC .
Hi Guys, I'm unable to get the selected customer profile in CSC when i make an AJAX call to some jsp. Thanks, Ayan
-
RD (Rogue Detector) or RLDP (Rogue Location Discovery Protocol)
Hi all, Cisco documentaion states that there are two ways for detecting Rogues. Rogue Detector Access Point You can make an AP operate as a rogue detector, which allows it to be placed on a trunk port so that it can hear all wired-side connected VLAN
-
I think that this toolbar came with a program which I downloaded called Dictionary Boss. Each time I bring up Firefox this "My Websearch Home Page" come up and replace Google. It seems to me that this websearch thing has become a part of FireFox. I h