Topic
  • 6 replies
  • Latest Post - ‏2013-06-20T10:21:42Z by SRIEAI
daniel64
daniel64
5 Posts

Pinned topic [DEV] How to retrieve service module name in Java implementation...

‏2012-03-12T16:17:35Z |
Hello,
I have a Java component, I would like to retrieve the service module name within a Java implementation as import component... I canonly get the current component (ServiceManager.INSTANCE.getComponent()) but I can't understand how to retrieve the running module...??...

Any idea ?
Thanks.

Daniel.
Updated on 2013-02-12T18:10:04Z at 2013-02-12T18:10:04Z by sbhatta6
  • ak1973
    ak1973
    7 Posts

    Re: [DEV] How to retrieve service module name in Java implementation...

    ‏2012-03-12T19:50:14Z  
    Hi;

    Did you try processInstance().getDisplayName() or processInstance().getName()??

    I guess these are part of com.ibm.bpe.api package to get process instance data in BPEL module.
    iak
  • Ronn78
    Ronn78
    12 Posts

    Re: [DEV] How to retrieve service module name in Java implementation...

    ‏2012-03-12T20:15:05Z  
    Hi,

    Try this -->
    SCAServices scaServices = this.getSCAServices();
    String serviceName = scaServices.getModuleName();
    System.out.println("Service Name: " + serviceName);

    Make sure to include this in Java Imports Tab-->

    import com.ibm.wsspi.sibx.mediation.esb.SCAServices;

    Thanks
  • daniel64
    daniel64
    5 Posts

    Re: [DEV] How to retrieve service module name in Java implementation...

    ‏2012-03-15T09:11:50Z  
    • Ronn78
    • ‏2012-03-12T20:15:05Z
    Hi,

    Try this -->
    SCAServices scaServices = this.getSCAServices();
    String serviceName = scaServices.getModuleName();
    System.out.println("Service Name: " + serviceName);

    Make sure to include this in Java Imports Tab-->

    import com.ibm.wsspi.sibx.mediation.esb.SCAServices;

    Thanks
    Hello,

    Thanks for your responses.
    Unfortunaltely, they both don't work as:
    - I don't use BPEL
    - the Java class is not an implementation of a primitive in the mediation flow

    To be more precise, see the location of the JavaComponent in the diagram attached.
    The generated code is the follwing:
    
    
    
    import com.ibm.websphere.sca.ServiceManager;   
    
    public 
    
    class JavaComposantImpl 
    { 
    /** * Default constructor. */ 
    
    public JavaComposantImpl() 
    { 
    
    super(); 
    }   
    /** * Return a reference to the component service instance for this implementation * class.  This method should be used when passing this service to a partner reference * or if you want to invoke this component service asynchronously. * * @generated (com.ibm.wbit.java) */ @SuppressWarnings(
    "unused") 
    
    private Object getMyService() 
    { 
    
    return (Object) ServiceManager.INSTANCE.locateService(
    "self"); 
    }   
    /** * Method generated to support implementation of operation "testoperation" defined for WSDL port type * named "Interface". * * Please refer to the WSDL Definition for more information * on the type of input, output and fault(s). */ 
    
    public String testoperation(Boolean input) 
    { 
    //TODO Needs to be implemented. 
    
    return 
    
    null; 
    }   
    }
    


    I would like to retrieve the running module name in the testoperation method of this class.

    Thanks.
    Daniel.
  • Ronn78
    Ronn78
    12 Posts

    Re: [DEV] How to retrieve service module name in Java implementation...

    ‏2012-03-15T19:24:16Z  
    • daniel64
    • ‏2012-03-15T09:11:50Z
    Hello,

    Thanks for your responses.
    Unfortunaltely, they both don't work as:
    - I don't use BPEL
    - the Java class is not an implementation of a primitive in the mediation flow

    To be more precise, see the location of the JavaComponent in the diagram attached.
    The generated code is the follwing:
    <pre class="jive-pre"> import com.ibm.websphere.sca.ServiceManager; public class JavaComposantImpl { /** * Default constructor. */ public JavaComposantImpl() { super(); } /** * Return a reference to the component service instance for this implementation * class. This method should be used when passing this service to a partner reference * or if you want to invoke this component service asynchronously. * * @generated (com.ibm.wbit.java) */ @SuppressWarnings( "unused") private Object getMyService() { return (Object) ServiceManager.INSTANCE.locateService( "self"); } /** * Method generated to support implementation of operation "testoperation" defined for WSDL port type * named "Interface". * * Please refer to the WSDL Definition for more information * on the type of input, output and fault(s). */ public String testoperation(Boolean input) { //TODO Needs to be implemented. return null; } } </pre>

    I would like to retrieve the running module name in the testoperation method of this class.

    Thanks.
    Daniel.
    Ok.. I believe this is outside your scope to get what you want. I would say get the service name in mediation and pass it to Java component.My two cents...
    Thanks.
  • sbhatta6
    sbhatta6
    1 Post

    Re: [DEV] How to retrieve service module name in Java implementation...

    ‏2013-02-12T18:10:04Z  
    Not sure if it will help you anymore as it's been a long time since you posted this question. I faced a similar problem yesterday. I am using a mediation module and a custom data handler to process outgoing data. I needed to access the module name from the data handler code. I created a class with a static variable and from within the mediation module I set the modulename in the static variable of the class. From within the data handler, I access the same static member of the class and get the module name back.

    Sanjay
  • SRIEAI
    SRIEAI
    2 Posts

    Re: [DEV] How to retrieve service module name in Java implementation...

    ‏2013-06-20T10:21:42Z  
    • sbhatta6
    • ‏2013-02-12T18:10:04Z
    Not sure if it will help you anymore as it's been a long time since you posted this question. I faced a similar problem yesterday. I am using a mediation module and a custom data handler to process outgoing data. I needed to access the module name from the data handler code. I created a class with a static variable and from within the mediation module I set the modulename in the static variable of the class. From within the data handler, I access the same static member of the class and get the module name back.

    Sanjay

    Hi,

     

    use the below code in custom mediation primitive

     


    import com.ibm.ws.sca.internal.container.Container;


    String module = Container.INSTANCE.getModule().getModule().getName();

    Thanks,

    Srikanth