Getting calling class name
Hi,
I have a project where it is imperative that i know the calling class and the called class name. I have a solution working where i place the caled class on a stack and record it as a possible calling class. However there must be a simpler means of doing this. My code is poor. Is there a method of getting the calling class on a classPrepareEvent so that i have the class and the calling class.
regards
ciaran
I suggest you start by taking a look at the example source code
for the trace application, which is described here:
http://java.sun.com/products/jpda/examples.html
The example source code is included in your J2SE 1.4.xx bundle
under the demo directory. Look in $JAVA_HOME/demo/jpda/examples.jar
To compile or run the examples, you need to add
$JAVA_HOME/lib/tools.jar to your classpath.
After you unpack examples jar, look for
com/sun/tools/example/trace/Trace.java
Similar Messages
-
How to get the class name of a page in oracle apex
Hi All,
Can anyone please let me know how we can get the class name of a page or region in oracle apex? I would also like to know how we get the DOM object ID for particular item.
I appreciate any help on this.
Regards
RajRajEndiran wrote:
Can anyone please let me know how we can get the class name of a page or region in oracle apex?What do you mean with class name? The name of the template (e.g. the css style class name)?
I would also like to know how we get the DOM object ID for particular item.Use firebug or inspect the source code of the rendered page to see the object IDs. Other then then, the typical ID of page items is the name of the item. For regions you can set your own ID. -
How to i get the class name ? please help me
hi friends
i want to know how to get the class name from my java program
public class sample
public static void main(String args[])
how to i get sample.
please help me.
thanks in advanceI can't recall which forum member gave the following solution, but it works
in static contexts and it's copy-and-paste friendly -- you don't hard-code the
name of the class, only a dummy class that you use to make this hack work:
public class Foo {
private static class Dummy{}
public static void main(String[] args) {
Class cls = Dummy.class.getEnclosingClass();
String name = cls.getName();
System.out.println(name);
} -
How to get the class name and field name dynamically
Hi
I have a class (ex: Contract) the fields (ex : a,b,c) .i need to get the class name and field name dynamically
ex
if( validation file for the field Contract.a){
return contract.a;
}else if(validation file for the field Contract.b){
return contract.b;
how to pass the field name and object dynamically
Please help me .............
Thanks in Advance..
Edited by: 849614 on Aug 11, 2011 6:49 AMYoungWinston wrote:
maheshguruswamy wrote:
Agreed, but IMO, i still feel its best if there is no tie in between consumer class level details and the database it talks to. A service layer is needed in between them.Sounds like you've done a bit of this before. Me, I've either been a modeller/DBA, doling out data, or a nuts and bolts programmer (and actually more toolmaker than apps, but did a bit of that too).
Do you know of a good book about the "middle ground" (ie, these service layers)? I understand it empirically, but haven't had a lot of exposure to it.
Winston
Edited by: YoungWinston on Aug 11, 2011 10:34 PM
PS: Apologies. Edited my previous post, presumably while you were composing your reply, when I finally realized what '.filed' meant.Most of my work is in web development, never been a DBA :) . The biggest 'concern' in my shop is 'separation of concerns'. The UI group reports up to a different IT head, the DB group reports up to a different IT head and so on. The looser the coupling between these systems, the lesser the project costs (Integration, QA etc) are. Martin Fowler's books contain good information about separation of concerns in an enterprise environment. The two books which i recommend are
[url http://www.amazon.com/Patterns-Enterprise-Application-Architecture-Martin/dp/0321127420]Enterprise Application Architecture and
[url http://www.amazon.com/Enterprise-Integration-Patterns-Designing-Deploying/dp/0321200683/ref=pd_sim_b_1]Enterprise Integration Patterns -
How to get the Class name of an API method?
Like most of us, it's difficult to know where every method within a Java class is. Also, many of the same methods are scattered throughout Java Classes. I know of two methods that retreive this... getClass().getName(). But, you must have an object to use these. Is there a way to find out what Class contains a method or Class variable thru an Applet or Java Application?? Obviously, I can look at API Docs; but this takes time.
Tks RandyRajEndiran wrote:
Can anyone please let me know how we can get the class name of a page or region in oracle apex?What do you mean with class name? The name of the template (e.g. the css style class name)?
I would also like to know how we get the DOM object ID for particular item.Use firebug or inspect the source code of the rendered page to see the object IDs. Other then then, the typical ID of page items is the name of the item. For regions you can set your own ID. -
Which is the best way for a called function to identify caller class name.
Which is the best way for a called function to identify the caller class name .
1)Using sun.reflect.Reflection from called function
Class caller = Reflection.getCallerClass(2);
System.out.println("Caller Class Name ::"+caller.getName());2) Analyzing current threads stack trace from called function
StackTraceElement[] stElements=Thread.currentThread().getStackTrace();
System.out.println("Caller Class Name ::"+stElements[3].getClassName());Is there any alternate ways to achieve the same .Which is the best way ?
Called function doesn’t have any arguments, I don’t want t pass any arguments from caller function to called function.
Plz help.
With kind regards
Paul798185 wrote:
Which is the best way for a called function to identify the caller class name .
Is there any alternate ways to achieve the same.SecurityManager
// 0 is the anonymous SecurityManager class
// 1 is this class (also works in static context)
// 2 is calling class
static Class getClass(int i) {
return new SecurityManager() {
protected Class[] getClassContext() {
return super.getClassContext();
}.getClassContext(); -
How does one call a class if one gets the class name from a database?
Hi,
I'm writing an application that needs to handle different types of input file.
Each type of input file will be handled by a different processing class.
I plan to use a controller class that will read from a database rows that each contain a file name and processor class name such that the class can then be used to process that file:
So on a table somewhere I might have relationships like:
file1.csv , ProcessorClassA
file2.csv , ProcessorClassB
file3.csv , ProcessorClassB
My hope is that if I need a new processor class, I will not have to change the controller class. I simply write the new class say, ProcessorClassC and put an entry in my table for:
file4.csv , ProcessorClassC
So, finally, the question...
I can read in the new class name into a string but how can I employ that class or instantiate objects of that new class and use their methods.
The rationale is that so that the controller class needs no further modifications no matter how many new processor classes are required.
Any ideas anyone?A factory class? I'm all ears... or is that another
days work...?Look e.g. here (or Google for "Factory Design Pattern"):
http://www.exciton.cs.rice.edu/JavaResources/DesignPatterns/FactoryPattern.htm -
How to get the class name static method which exists in the parent class
Hi,
How to know the name of the class or reference to instance of the class with in the main/static method
in the below example
class AbstA
public static void main(String[] args)
System.out.println(getXXClass().getName());
public class A extends AbstA
public class B extends AbstA
on compile all the class and run of
java A
should print A as the name
java B
should print B as the name
Are there any suggestions to know the class name in the static method, which is in the parent class.
Regards,
Raja Nagendra KumarWell, there's a hack you can use, but if you think you need it,Could you let me the hack solution for this..
you probably have a design flaw and/or a misunderstanding about how to use Java.)May be, but my needs seems to be very genuine..of not repeat the main method contents in every inherited class..
The need we have is this
I have the test cases inheriting from common base class.
When the main method of the test class is run, it is supposed to find all other test cases, which belong to same package and subpackages and create a entire suite and run the entire suite.
In the above need of the logic we wrote in the main method could handle any class provided it knows what is the child class from which this main is called.
I applicate your inputs on a better way to design without replicating the code..
In my view getClass() should have been static as the instance it returns is one for all its instances of that class.
I know there are complications the way compiler handles static vars and methods.. May be there is a need for OO principals to advance..
Regards,
Raja Nagendra Kumar
Edited by: rajanag on Jul 26, 2009 6:03 PM -
Getting the class name from within the compiled class file
hey!
I was wondering (i know its possible) how to read a .class and get the name of the class. ok that made not much sense^^ so, You have a file: c:\f.class but it wont run because the file name has to be the same as the classes name, right? so how can you read the class file i guess in binary mode to receive the correct class name.
I saw inside my f.class i have "realname.java" so i know now that the name of the class file should be realname.class, i tried ways to extract it from the class file but never had any success.
i think i need to study english^^
ps: i need this because i have some class files sent to me and the file names have been changed so they wont work, they only work when i open the class file in notepad and find out what its real name should be and then rename the file.
Edited by: forgotmydamnpass on May 7, 2009 11:23 AMah looks interesting, problem is i cant use it.. im prone to errors!
import java.net.URLClassLoader;
public class NewMain {
* @param args the command line arguments
public static void main(String[] args) {
FileClassLoader loader = new FileClassLoader();
Class clazz = loader.createclass("c:\\f.class");
Method method = clazz.getName();
}apparently "createclass" doesnt exist :/
FileClassLoader = cannot find symbol
Method = cannot find symbol -
when a class(A) call another class(B),how to get B's classname.
e.g.
class A{
public void test(){
B b = new B();
how to use a program find Class A call Class B or more ?
Class C{
public static void main(String[] args){
A a = new A();
s = //how to get B's Classname in a;
System.out.println("Class A call ClassName:"+s);
}The World's Most Important Java Class:
(Corollary to the World's Most Important Trig Formula)
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html -
How to get calling jsp name?
We are implementing iStore 12.1.3
We have a jsp which can be called from multiple jsps. When the jsp is processed, navigation should go back to the calling jsp.
Is there any in-built API which provides calling jsp name?
Please advise urgently.
Thanks in advanceIs it a custom jsp or seeded jsp?
you can go back to previous page programmatically, only if previous page reference is passed thru request object
if it is seeded jsp, you will need to check if calling jsp is passing the name of page to destination page through request object.
if it is custom jsp, introduce code like below on all the source/calling JSPs.
<input type=hidden name="fromRef" value="<%=IBEUtil.htmlEncode("<name of page>")%>">
and on processing page, write code to forward to fromRef.
e.g. <jsp:forward page="<%=request.getParameter("fromRef")%>"/>
thanks,
Hrishikesh -
How to get the class name of all available subclasses
Hi there!
Im developing an eComerce site as part of my studies this semester using JSP and mySQL. It's part of a bigger management system for a fictional company.
In the user interface, when adding new products to be available for sale on the website, I want the administrator to be able to choose what kind of product is being added. In the database I have the superclass[i] products with subclasses[i] harddrives, monitors etc.. The question is, can I somehow get the names of the subclasses constrained to a certain superclass? Maybe this question is more related to SQL querys than to JSP, but any help is appreciated:-)First of all it is not conventional (or at least I find it very confusing) to call things as super class or sub class when referring to them in the database.
Why? because super class and sub class are really concepts in Object Oriented Programming languages, and probably (not sure) in Object Oriented Databases.
So I would call them main categories of products and sub categories of products.
And in databases I assume you have tables?
So say the table with main categories would have a primary key and a text field. The primary key is just like an index, and the text field holds the Main Category.
Similarly you would have another table representing sub categories.
But how would you associate a set of sub categories to each main category?
For this you would need a Foreign Key in the sub categories table.
The foreign key of a sub category maps to the primary key of the main category. Get it? If not you'll need to learn relational databases.
So if you know SQL you could write a SELECT statement in MySQL as follows:
SELECT product_category_name FROM product_sub_category psc, product_main_category psm WHERE psc.product_main_category = psm.product_main_category AND psm.product_main_category = 'Whatever Cagegory Name';
Message was edited by:
appy77 -
How can I get the name of the Application I use to connect to the DB from within a procedure/view?
The user ID used has no DBA or system privileges, so it can not use v$Session....
Thanks in advance for any help
JeromeIn the application call the procedure
DBMS_APPLICATION.set_client_info('Client Application Info');
The will set the client_info field in v$session.
You can also get the same value calling the function in the stored proc
DBMS_APPLICATION.GET_CLIENT_INFO -
How to get main class name in running program?
How can I get classname, which main method is executed? Of course in running program?
Please help,
ChrisSomething like (not tested this)StackTraceElement[] foo = new Throwable().getStackTrace();
String whichClass = foo[foo.length-1].getClassName(); -
Let's assume I have the following:
fileA.cfm > includes fileB.cfm > includes fileC.cfm
Within fileC.cfm, how can I figured out that fileB.cfm was the page that called it? I was looking through getPageContext() for any revalent information, but I'm stumped. If i use cgi.path_info that's invalid as it would give me fileA.cfm. This has to be something obvious that I'm missingOne way would be to use the session scope...
fileA.cfm source code:
<cflock...>
<cfset SESSION.last_source_location = GetFileFromPath(CGI.CF_TEMPLATE_PATH)>
</cflock>
<cfinclude template="fileB.cfm">
fileB.cfm source code:
<cflock...>
<cfset SESSION.last_source_location = GetFileFromPath(CGI.CF_TEMPLATE_PATH)>
</cflock>
<cfinclude template="fileC.cfm">
fileC.cfm source code:
<cfif IsDefined("SESSION.last_source_location") AND Len(SESSION.last_source_location) AND SESSION.last_source_location IS "fileB.cfm">
<!--- Source location was valid. --->
<cfelse>
<!--- Source location was not valid. --->
</cfif>
<cfset SESSION.last_source_location = ""> <!--- Reset for use again. --->
Maybe you are looking for
-
I have created an apple ID in Germany, but would like to get apps from the US App store, is this possible?
-
Error while install IM with LDAP repository
Hi, like the title says, I am getting error immediately when deploy idm.war on sjsas(glassfishv2): Starting internal database server ... com.waveset.util.ConfigurationError: ==> java.sql.SQLException: Connection is broken: java.lang.OutOfMemoryError:
-
Multiple facts with non-conforming dimensions
Hi, I have a question re: using multiple facts in a report, where one of the facts has a non-conforming dimension. I have two metrics: "PAYROLL" and "UNRECONCILED DIFFS". The payroll metric is at the employee level, but the "UNRECONCILED DIFFS" is no
-
Pxi 1042 configuration for Real-Time
I have purchased PXI-1042 controller 8187 one module for data capturing. I want to configure the said pxi for Real-Time purposes, so what steps should I follow? thanks Abbas Solved! Go to Solution.
-
Recording vinyl with Audacity - not having any luck
I'm trying to record my vinyl collection using audacity and not having much luck. I've got the line in and can get the red recording cursor moving but no waveform appears. I have followed the info on the wiki but I cannot get any further. The wiki is