Automatically detect the caller class!

Guys,
I have a simple but "sounds-like-general-and-interesting" doubt..
I have a class 'A' and another class 'B'. I have a method in 'A' called 'a' calling a method in class 'B' (which is 'b').
suppose the control is inside the method 'b' of the class 'B'.
Now, the doubt is
how can I find out that it was class 'A' who called the method 'b' of class 'B' from within the method 'b'?
the scenario is a simpe loging scenario where the class 'B' is a Logger class and I want to automatically detect the class calling this component from within this component so that it can be logged too.
Hope my problem is clear. Thankx in advance for the replies.. am stuck and confused too.. and hop there's a solution for this
regards
Manesh

mgumbs is right - typically a Logger class will accept a context (Object) to indicate where the message has come from. Sometimes people pass in "this", sometimes they pass in "this.class" or sometimes they'll log on behalf of another class. It's pretty much the same solution - if it's needed you should supply it.
One method made possible in J2SDK-1.4 is using a stack trace to find out what the calling class/method is. Perhaps the only way to do that would be to throw a new Exception and get hold of its stack trace elements. I suspect that this would add significant overhead, though, and I certainly wouldn't recommend it!

Similar Messages

  • To access a package, the calling class must reside in the root/parent direc

    My goal was to be able to access my package from anywhere within the
    high level root folder (d:\zJava). But it seems the invoking class MUST
    RESIDE IN THE TOP LEVEL PARENT DIRECTORY of the package. Was Java
    designed to behave this way?
    D:\zJava\zsamples\com\zswingpackage1>     <-- packages successfully compiled here
         swing_optgrp_eg1.{class/java}
              package com.zswingpackage1;
              public class swing_optgrp_eg1 extends JFrame implements ItemListener {
    D:\zJava\zsamples\com> <-- classes residing here could NOT successfully                    access the package 'com.zswingpackage1'. The third                    level subfolder is 'com'.
         package_test4.java
              /* Following import stmt. causing RUN-TIME error "Exception in thread     "main" java.lang.NoClassDefFoundError: com/zswingpackage1/swing_optgrp_eg1". */
              import com.zswingpackage1;
         Package_Test4.class          
         /* Unsuccessful remedies:
         i) D:\zJava\zsamples\com>java Package_Test4
                   -classpath .;d:\zJava\zsamples\com\zswingpackage1
                   -classpath .;d:\zJava\zsamples\com
                   -classpath .;d:\zJava\zsamples (also used in compile)
                   -classpath .;d:\zJava
         ii) ran from the root/parent directory of the package d:\zJava\zsamples),with and without classpath i.e.
              D:\zJava\zsamples>java com\Package_Test4 [-classpath .;d:\zJava\zsamples]
         iii) ran from the top level directory (d:\zJava), with and without classpath i.e.
              D:\zJava>java zsamples\com\Package_Test4 [-classpath .;d:\zJava\zsamples]
         Possible causes:
              - maybe the above behaviours are by design i.e. the calling class/program CANNOT be stored within the package hierarchy?
    D:\zJava\zsamples\net> <-- classes residing here could NOT successfully access the package 'com.zswingpackage1'. The third level subfolder is 'net'.
         package-test6.java
              /* Following import stmt. causing RUN-TIME error "Exception in thread "main" java.lang.NoClassDefFoundError: com/zswingpackage1/swing_optgrp_eg1". */
              import com.zswingpackage1;
         Package_Test6.class
         /* Unsuccessful remedies:
         i) D:\zJava\zsamples\net>java Package_Test6
                   -classpath .;d:\zJava\zsamples\com\zswingpackage1
                   -classpath .;d:\zJava\zsamples\com
                   -classpath .;d:\zJava\zsamples (also used in compile)
                   -classpath .;d:\zJava
         ii) ran from the root/parent directory of the package (d:\zJava\zsamples), with and without classpath i.e.
              D:\zJava\zsamples>java net\Package_Test6 [-classpath .;d:\zJava\zsamples]
         iii) ran from the top level directory (d:\zJava), with and without classpath i.e.
              D:\zJava>java zsamples\net\Package_Test6 [-classpath .;d:\zJava\zsamples]
         Possible causes:
              - maybe the above behaviours are by design i.e. the calling class/program MUST be stored in the parent folder of the package hierarchy?
    **D:\zJava\zsamples>     <-- classes residing here SUCCESSFULLY accessed package 'com.zswingpackage1'. NO -classpath parms. were necessary!
    D:\zJava\ <-- classes residing here could NOT successfully access the package 'com.zswingpackage1'. Similar scenarios as above.
    D:\zJavaB\ <-- classes residing here could NOT successfully access the package 'com.zswingpackage1'. I purposely created another folder with the 'B' suffix. Similar scenarios as above.
    My PC configuration:
         java version "1.4.0_01"
         Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
         Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)
         JRun 4 (Build 47304)
         WinNT 4.0 SP5
         IE 5.50
         CLASSPATH=.;D:\jakarta-tomcat-3.3.1\lib\common\servlet.jar;
              C:\JRun4\servers\default\default-ear\default-war\WEB-INF\classes
         JAVA_HOME=C:\j2sdk1.4.0_01
         Path=C:\j2sdk1.4.0_01\bin;C:\WINNT\system32;C:\WINNT;
              C:\Program Files\Network Associates\PGPNT;C:\Program Files\MTS;d:\MSSQL7\BINN
    Thank you so much for your expertise.

    Hello,
    I think that you use the import-declarations incorrectly.
    Your code says:
    import com.zswingpackage1;
    ... The meaning of the above declaration is the following: Import the class "zswingpackage1" from the package "com". The compiler cannot find that class, but it is probably never asked to find it in your code, so it won't report an error.
    If you want to import the whole package use the following declaration instead:
    import com.zswingpackage1.*;
    ... That means: import all classes from from the package "com.zswingpackage1".
    You can also import just the classes needed, e.g.:
    import com.zswingpackage1.swing_optgrp_eg1;
    ... I hope that does the job.
    S&oslash;ren

  • I am using an Apple TV in a hotel with free wi-fi, the Apple TV automatically detected the wi-fi network, and I'm am signed in to the Apple iTunes Store, but the screen continues to show cannot connect to iTunes Store!

    I am using a newly purchased Apple TV in a hotel room that has free wi-fi, the Apple TV has detected the network automatically, I am signed in to the Apple iTunes Store, using my Apple ID, and password, but the screen always says "cannot connect to iTunes Store"

    Try streaming other content.
    If the hotel's network requires login via webpage then it won't actually be connected and you will need to contact the provider to gain access.

  • Xorg Automatically Detects The Wrong 'Primary' Monitor

    Running KDE on an HP dv9910us with the nVidia binary drivers.
    lspci for the video card is:
    00:12.0 VGA compatible controller: NVIDIA Corporation C67 [GeForce 7150M / nForce 630M] (rev a2)
    I have an external monitor that it will detect and configure as the primary monitor on every boot. The fix is simple, I launch the nVidia X Server Settings and check 'Make this the primary display for the X screen' and things switch over just fine, however this needs done at every boot.
    I'm sure I could export the X configuration file and that would take care of it, but I would prefer to leave the system to auto-configure each time (it feels right to have it this way). Is there a way to ensure that it will detect the built into the laptop screen as the default?
    Instinct is telling me that it is choosing the larger display as the default:
    Internal screen: 1440x900
    External screen: 1920x1080
    Any thoughts would be appreciated.

    I finally found what appears to be the solution:
    https://bbs.archlinux.org/viewtopic.php?id=120173
    Not sure how I was unable to find that before hand.
    Also, there were many files in xorg.conf.d:
    -rw-r--r-- 1 root root 1761 Sep  9 13:12 10-monitor.conf
    -rw-r--r-- 1 root root  193 May  5 23:56 10-monitor.conf~
    -rw-r--r-- 1 root root  192 May  5 23:56 10-monitor.conf.broken
    -rw-r--r-- 1 root root 1772 May  5 23:42 10-monitor.conf.bak-2012050502
    -rw-r--r-- 1 root root 1959 May  5 23:39 10-monitor.conf.bak-20120505
    -rw-r--r-- 1 root root 1696 Apr 20 13:36 10-monitor.conf.backup
    -rw-r--r-- 1 root root 1696 Feb 11  2012 10-monitor.conf.PERFECT.bak
    -rw-r--r-- 1 root root 1727 Feb  6  2012 10-monitor.conf.working-twinview
    How does this directory work? Will all of these files be used for configuration, or just the ones ending in .conf?

  • How do I go about setting up my new wireless all-in-one Epson XP-215 printer to my MacBook Pro? The system is not automatically detecting the printer ad the furthest I get is "System" keychain user and pswd but I am a new user to Mac.

    I am a new user to Mac and trying to set up an Epson XP-215 All-in-One printer without any success. The Mac Book Pro is not recogising the Printer automatically and when following the instructions to add the printer, it gets as far as a display box for teh user and password for "System" Keychain but I am not sure what info to add there...
    The printer is meant to have a function calle dAir Print also that is meant to be used for Mac but I cannot figure out any of this! Why would the MacBook Pro not automatically pic up the printer? Please help...

    If you have not already done so, you should read the user manual that came w/the printer and/or contact Epson tech support. 
    Check out the following KB Articles: 
    http://support.apple.com/kb/PH14141 OS X Mavericks: Reset the printing system 
    http://support.apple.com/kb/HT3669 Printer and scanner software available for download 
    Also check out What to do when you can't print 

  • Name of  the "caller" class

    Hello,
    Is it possible in a class to know the name of the class that instanciated it ?
    Thank you in advance,
    Thierry

    or another story i heard.
    A trying to steal B's hub caps in B's car parked in B's driveway.
    B starts his car and reverses it and in the process runs over A's hand.
    A sues B for injury and other damages.
    just something i heard.
    thought it was funny

  • Does anyone know of an ap that will auto call forward all voice calls from my iphone4 to a different number (office) at set times each day? IE - i want my business iphone to automatically call forward at 0830am weekdays and cancel the call forward at 6pm

    I am trying to find an app that will automatically forward all voice calls at preset times each day
    IE - at 083am weekdays
    and automatically cancel the call forward at 6pm weekdays
    At the moment i am doing it manually with alarms set to remind me
    Seems a pretty basic "want" but - i cant find anything
    And APPLE - make it easier to find APPS in the APP store - wy not have a search feature that you can type in what you are looking for??
    Thanks!!

    There are no apps to do what you want, that's why you can't find any. No app would have access to the necessary API's to do this, thus only Apple could implement such. You can suggest such to Apple here:
    http://www.apple.com/feedback/iphone.html
    Another suggestion is to look at Google Voice. I don't know if it offers these specific features or not, but it is highly customizable.

  • Getting the calling object reference / class?

    Dear forum members,
    Is it possible for A in the below example to get that B was the "caller"?
    class A {
      A() {
      public void someMethod(String text) {
        System.out.println("I was called with: " + text);
        System.out.println("I was called by: " + thatMagicWayToGetCallerClassOrReference());
    class B {
      public static void main(String[] args) {
        A a = new A();
        a.someMethod("HOLA HOLA");
    }

    Another way of getting the class of your caller is to use a SecurityManager object. getClassContext() is protected but you can get at it by subclassing SecurityManager (it works if you just instanciate the manager without installing it). This gives you a reference to the Class object itself where the stack trace returns only the class name. Bear in mind that the class in question will be several items up the array, the first entry is the SecurityManager itself, the second the called class.
    However, I agree with others it doesn't sound like the best design. If you're having trouble with not being able to change the interface specifications to pass the extra information then consider using a static reference, if necessary a ThreadLocal. What happens if you want to call the offending method indirectly through some central method at some future time? You've lost the call origin data.
    Why can't you simply add a parameter to the offending call?

  • 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
    Paul

    798185 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 to prevent voice over saying the caller number or name automatically in iphone?

    hi, i'm a new member of apple world,
    i'm using voice over in my iphone 5s, when i receive a call, voice over automatically say the calling number or name with the ring tone, how can i set
    voice over to prevent it saying the caller number or name ??

    Same problem, which is extremely inconvenient because I like to use my earphones to listen to Pandora while I work. Not every time, but most of the time I plug in my earphones, the iPod software starts playing the last song that was played. Stopping the music via iPod or pressing the Home button for 10 seconds to force quit iPod doesn't stop the music as it will just automatically start playing again. Sometimes if I'm lucky, plugging the earphones in very quickly avoids this problem -- but like I said, it's a cross my fingers and hope I get lucky kind of thing.
    I'm using the newer 3G model, which I've had for only about a month. I did not have this problem with my old 2G iPhone.
    Someone in another thread said it's a hardware fault and suggested exchanging the phone for a new one. Can anyone confirm this?

  • ISP has floating IP and changes several times a day - how do I set Foxfire to automatically detect and update the IP when I attempt to open the browser?

    If I log off my ISP automatically changes the IP address, when I used Windows Explorer I was able to tell it to automatically detect the new IP so I did not have a problem. With Foxfire I have to manually go out get the new IP and then open the browser - this is a PIA.

    When entering the URL either as your home page or new tab page, I suggest using the full URL https://www.google.com/ since otherwise there is a slight delay as Google redirects Firefox to the secure page.

  • Call classes from another project

    Hi,
    i have a (i hope) simple question.
    Meanwhile i have a lot of custom coding which i uploaded to my J2EE as PAR files from NWDS.
    For several projects i have similar requirements (e.g. read customers information etc.), so I generated a "base" project in nwds and deployed it.
    In NWDS project properties i can set the "Java Build Path" to this project and i am able to call the methods that i wrote in this project. But only in NWDS.
    When i deploy the project to J2EE i get runtime errors that classes are not found, so i think i have to customize sth. in portalapp.xml to set the reference
    I tried several things with "SharingReference" etc. but nothing worked.
    Could anyone tell me the steps i have to do?
    I know i could create a jar file which i link in my project but i want a central project where i can change coding, deploy it again, and all projects automatically use the actual classes.
    Many thanks
    regards
    Alex

    Hi Min,
    i tried this but get errors.
    The project par with the baseclasses has the name "com.xxx.baseclasses.par", the package in the project where the classes are placed is "com.xxx.baseclasses.usermanagement;"
    So i tried it in portalapp.xml of my other project with the following lines
    <application-config>
        <property name="SharingReference" value="usermanagement,com.xxx.baseclasses"/>
        <property name="SharingAccess" value="shared"/>
      </application-config>
    I also tried com.xxx.baseclasses.usermanagement, but no luck. In default trace i get:
    java.lang.NoClassDefFoundError: com.xxx.baseclasses.usermanagement.ZBVUser
    Do i have to set the reference in a different way or do i have to change sth. in my baseclasses project?
    Many thanks
    Regards
    Alex

  • Detecting the source of a method invocation.

    Within a given method, is there a way to detect what class/method made the invocation call?
    I need to find a way to modify instance variables within a method, based on the invoking class ... I thought of navigating back through the Stack, but I am working with a multi-threaded application so I fear that I cannot absolutely depend on the last Stack call being the actual invoking class/method. Any ideas? - please help.
    Many thanks,
    Thomas

    How does one access the method invocation stack?I'm not sure if an easier way exists, but you can extend SecurityManager to fetch the Class context of the current Thread, which will provide you with an array of Class obejcts, ordered according to the method invocation stack. Thus, you can determine what Class invoked a particular method, but you can not determine what Object (not via the SecurityManager funcationality).
    Here is a simple class I often use for such a need (excuse any formating issues- or misspellings in the documenation)... ... although, it should be stated, this class may not work in certain environments- specifically ones that deny permission "createSecurityManager".
    * This class provides static utility methods for retrieving information
    * on the class context.  The methods in this class can provide a
    * resource with a list of the classes that invoked it, thus allowing
    * clases to determine if a particular method is being accessed by
    * the proper caller or allow Class variables to be initialized statically,
    * with out having to instantiate the type.
    * <p>This class is meant to provide simple functionality in familiar
    * environments.  Its funcationality may not work properly when executing
    * in an enviroment with strigent security permissions.  Specifically, if
    * permission is denied to construct a new SecurityManager instance, the
    * methods of this class will fail.
    * @author: Sean Flanerry
    public final class ClassLookup extends SecurityManager {
      private static final ClassLookup instance = new ClassLookup();
      private ClassLookup() { }
      * This method returns the class context for the current thread in format
      * <ul>
      * <li>Class for currently executing method
      * <li>Class that invoked the above method
      * <li>Class that invoked the above method...
      * </ul>
      * The first two elements in the returned array will be of type ClassLookup.
      * @see java.lang.SecurityManager#getClassContext()
      public static Class [] fetchClassContext() {
        return instance.getClassContext();
      * This method returns the Class that invoked this method.  This method
      * is used primarily by static initializers that have to retrieve a handle
      * to the java.lang.Class instance that wraps the current type, but that
      * can not instantiate the current type, eg <br>
      * <code>public static final Class currentClass = ClassLookup.getCallingClass();
      public static Class getCallingClass() {
        return instance.getClassContext()[3];
      * This returns the Class that invoked the current method on the calling
      * Class.  If for example, Race.startRace() invokes Runner.sprint(), Runner.sprint()
      * can determine what class invoked it by calling this method.  In other
      * words, this method lets other methods determine which class invoked
      * it.
      * <p>Remember that this method returns a Class instance for which
      * ever type contains the method which invoked the caller so the
      * Object returned by this method might be the caller's type if the
      * caller was spawned by a method with in the same class.  Consider,
      * <ul>
      * <li>Race.start() invokes
      * <li>Runner.sprint() which invokes
      * <li>Runner.fatigue()
      * </ul>
      * If Runner.fatigue() invokes this method, an instance of Runner.class will
      * be returned, <b>not</b> Race.class because fatigue was invoked by sprint.
      * <p>This method is typically used by resources that wish to determine
      * if the current method is being invoked via the proper context, ie the
      * invoking class is a trused resource.
      public static Class getInvokingClass() {
        return instance.getClassContext()[4];
      public static void main(String args[]) {
        Class [] c = fetchClassContext();
        for (int i = 0; i < c.length; i++) {
          System.out.println(c.getName());

  • Where does the java classes go?

    I normally use IntelliJ which automatically puts the java class and the jsp where they are meant to go.
    Can some help me.
    Can someone please tell me where to put the java class, i have put the jsp pages in the webapps\ROOT but where does the java classes go?
    Edited by: Tinkerbelle on Jul 24, 2008 1:46 AM

    Tinkerbelle wrote:
    sorry being stupid i do that sorry,
    If i change the class to type (as someone said in a previous post)That would only work if you already put the bean in the session scope.
    Did you try what PaulOckford wrote?
    >
    i get this error:
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP:
    An error occurred at line: 6 in the generated java file
    Only a type can be imported. com.database.contactDB resolves to a packageDo you have a package structure that looks like this:
    com
    com/database/ <-- This is where contactDB.class is located
    com/database/contactDB/
    Because that is what the compiler is saying. Though it may be thrown off by case (see below)
    P.S. If you use the jsp:useBean you do not need the import statement which appears to be where the error occurs. (One of the things that makes JSPs so hard to debug is the fact that the error line in the generated java file as referenced above is never the same as the line in the JSP file).
    >
    An error occurred at line: 3 in the jsp file: /login.jsp
    database.contactDB cannot be resolved to a type
    1: <%@ page import="com.database.contactDB" %>
    2:
    3: <jsp:useBean id='db'
    4: scope='session'
    5: type='database.contactDB'/>
    6: <html>
    And to be ultra clear - you did compile contactDB from a .java file to a .class file, and the class is called contactDB and not ContactDB correct? The class name is case sensitive and should be the exact same case in the useBean and import statements as in the real class name.
    >
    An error occurred at line: 3 in the jsp file: /login.jsp
    database.contactDB cannot be resolved to a type
    1: <%@ page import="com.database.contactDB" %>
    2:
    3: <jsp:useBean id='db'
    4: scope='session'
    5: type='database.contactDB'/>
    6: <html>
    Stacktrace:
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:93)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
         org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.26 logs.
    Apache Tomcat/5.5.26Edited by: stevejluke on Jul 24, 2008 7:33 AM
    Fixed compile from .class file to a .java file to compile from a .java file to .class file

  • Capturing the caller object

    I used to be doing like this:
    myTextObj.addCaretListener(new MyCustomCaretListener(myTextObj, ..., ...));because the constructor can't access the event and its source object. But current project has so many of these types of calls. Is there a way by which the constructor could automatically access the caller or registerer object? This is not a Swing question, but a more general one I suppose.

    There are a couple of ways. I agree with the last poster, an explanation of why you need this might lead to more helpful suggestions.
    1 - Use a Factory object. Assuming you are passing the same parent to multiple children, you could create a Factory object that takes the parent in its constructor. this object would then have methods to create the children and pass the parent as part of the parameters to child constructor.
    2 - Use inner classes which have a hidden parent in them.
    public class Outter {
         private String name;
         public Outter(String name) {
              this.name = name;
         public String getName() {
              return name;
         class Inner {
                     // The hidden parent
              Outter getParent() {
                   return Outter.this;
         public static void main(String[] args) {
              Outter outer = new Outter("Fred");
              Inner inner = outer.new Inner();
              System.out.println("Outter:" + outer.getName() +
                                     " Inner:" + inner.getParent().getName());
    } Both these suggestions, while workable, should be examined in the context of your project. It would be very easy to make the code less readable or just plain wrong, by using either of these techniques.
    Edited by: m0smith on Oct 10, 2007 9:27 PM

Maybe you are looking for

  • How to get extended object id (field OBJEC-REALO)

    Hi, anybody knows  where extended object id are stored, or how can I get this value? I have object id but i also need extended objetc value. I suppose that a function module exists to get this value, but I didn't find it. My program doesn't use PCH l

  • EJB migration from an existing jar

    Hi, I have a jar containing my ejbs with descriptors(jboss/weblogic). I have created an enterprise application project in NWDS. Is there any way i can directly put this ejb jar into ear project without using migration plugin. I will change the descri

  • Idoc Type SYIDOC01

    Has anyone already worked with idoc Type SYIDOC01, message type SYIDOC? Is there any way to use this Idoc to post idoc types that do not exist in an EBP SRM 3.0 system? If so, which process code should be used? thanks in advance, Raquel.

  • Flash player bar can't scaling in hi-dpi PC.(13.3 inch 2560x1440)?

    I am using a new NEC lavie laptop(13.3 inch) with a 2560 x 1440 display. Though in general the high-DPI scaling works pretty well, Flash player bar does not scale with the rest of the website. For example, when I watch a Youtube video, the text, obje

  • Skype with Ipod Touch?

    There seems to be an application that allows you to use Skype on the Touch. If so, can you use headphone/mike for the Iphone on the Touch?