Friday Aug 10, 2012

Google MAP APIv3 with ADF

James Taylor wrote nice sample code for integrating Google Map with ADF. Unfortunately, As Google Map API has been upgraded to v3, we need to make a little bit of changes to get it working. Here is the sample code.

     <f:facet name="metaContainer">

        <af:resource type="javascript" source="https://www.google.com/jsapi?key=[API  Key]"/> 

          <af:resource type="javascript">

  google.load("maps", "3",  {other_params:"sensor=false"});

  var map;

  var marker;

  function initialize() {

    var myLatlng = new google.maps.LatLng(-34.397, 150.644);

    var myOptions = {

      zoom: 8,

      center: myLatlng,

      mapTypeId: google.maps.MapTypeId.ROADMAP

    }

    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

  }

  google.setOnLoadCallback(initialize);

          </af:resource>

        <af:resource type="javascript"> 

                          function doNavigate(evt) 

                          { long = evt.getSource().getProperty("long"); 

                            lat = evt.getSource().getProperty("lat");

                            var center = new google.maps.LatLng(lat, long);

                            map.setZoom(15);

                            map.setCenter(center);

                            marker = new google.maps.Marker({position: center,map: map});

                            marker.setMap(map);

                          } 

        </af:resource> 

        </f:facet>

Tuesday Oct 04, 2011

Coherence*Web Session clustering between WebSphere and WebLogic

Briefly describing the needed steps to share session information between WebSphere 6.x and WebLogic 10.x

Steps for WLS 

1. java -cp coherence.jar;coherence-web.jar com.tangosol.coherence.servlet.WebPluginInstaller [WLS_HOME] -install

2. java -jar webInstaller.jar SessionTest.war -inspect -server:WebLogic/10.x

3. Modify coherence-web.xml 
    <param-name>coherence-session-cookie-domain</param-name>
    <param-value>.test.com</param-value>

<param-name>coherence-session-cookie-path</param-name>
    <param-value>/</param-value>

<param-name>coherence-servletcontext-clustered</param-name>
    <param-value>true</param-value>

    <param-name>coherence-enable-sessioncontext</param-name>
    <param-value>true</param-value>

<param-name>coherence-scopecontroller-class</param-name>
    <param-value>
       com.tangosol.coherence.servlet.AbstractHttpSessionCollection$GlobalScopeController
    </param-value>
<param-name>coherence-session-id-length</param-name>
    <param-value>32</param-value>

3. java -jar webInstaller.jar SessionTest.war -install

4. Insert those two classes(MyCookieHelper, MyDefaultFactory) into the SessionTest.war file.
----------------------------------------------------
package com.tangosol.coherence.servlet.weblogic81;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

import com.oracle.FileLogWriter;
import com.tangosol.net.CacheFactory;
import com.tangosol.net.cache.LocalCache;

public class MyCookieHelper extends CookieHelper {
// protected static final char SUFFIX_SEPARATOR = 46;
private LocalCache m_cacheFailover;
private String m_sConfiguredJvmRoute;
private FileLogWriter fileWriter;
public MyCookieHelper(
com.tangosol.coherence.servlet.SessionHelper.Factory factory,
ServletContext ctx) {
this(factory, ctx, null);
}

public MyCookieHelper(
com.tangosol.coherence.servlet.SessionHelper.Factory factory,
ServletContext ctx, String sJvmRoute) {
super(factory, ctx);
fileWriter = new FileLogWriter();
m_cacheFailover = new LocalCache(128);
m_sConfiguredJvmRoute = sJvmRoute;
}

public String decodeCookie(HttpServletRequest req) {
String sSessionId = super.decodeCookie(req);
CacheFactory.log("before :" + sSessionId);
fileWriter.writeToFile("before :" + sSessionId);
// WebLogic Session
if (sSessionId != null) {
int ofSeparator = sSessionId.indexOf('!');
if (ofSeparator >= 0) {
String sServerSuffix = getWebLogicAffinitrySuffix();
String sSessionSuffix = sSessionId.substring(ofSeparator);
sSessionId = sSessionId.substring(0, ofSeparator);
if (!sSessionSuffix.equals(sServerSuffix))
m_cacheFailover.put(sSessionId, sSessionSuffix);
}
}

// WebSphere Session
if ((sSessionId != null) && (sSessionId.length() > 4) &&(sSessionId.startsWith("0000"))) {
sSessionId = sSessionId.substring("0000".length());

int ofSeparator = sSessionId.indexOf(getWebSphereAffinitySuffix());
if (ofSeparator >= 0) {
String sServerSuffix = getWebSphereAffinitySuffix();
String sSessionSuffix = sSessionId.substring(ofSeparator);
sSessionId = sSessionId.substring(0, ofSeparator);

if (!sSessionSuffix.equals(sServerSuffix)) {
this.m_cacheFailover.put(sSessionId, sSessionSuffix);
}
}
}
CacheFactory.log("after :" + sSessionId);
fileWriter.writeToFile("before :" + sSessionId);
return sSessionId;
}

public String decodeUrl(HttpServletRequest request) {
String sSessionId = super.decodeUrl(request);
CacheFactory.log("before :" + sSessionId);
fileWriter.writeToFile("before :" + sSessionId);
if (sSessionId != null) {
int ofSeparator = sSessionId.indexOf('!');
if (ofSeparator >= 0)
sSessionId = sSessionId.substring(0, ofSeparator);
}
   if ((sSessionId != null) && (sSessionId.length() > 4) && (sSessionId.startsWith("0000")))
   {
     sSessionId = sSessionId.substring("0000".length());

     int ofSeparator = sSessionId.indexOf(getWebSphereAffinitySuffix());
     if (ofSeparator >= 0)
     {
       sSessionId = sSessionId.substring(0, ofSeparator);
     }
   }
   CacheFactory.log("after :" + sSessionId);
   fileWriter.writeToFile("before :" + sSessionId);
return sSessionId;
}

public String getWebSphereAffinitySuffix() {
return ":";
}

public String getWebLogicAffinitrySuffix() {
return "!";
}
}
----------------------------------------------------
package com.tangosol.coherence.servlet.weblogic103;

import com.tangosol.coherence.servlet.SessionHelper;
import com.tangosol.coherence.servlet.weblogic81.MyCookieHelper;
import javax.servlet.ServletContext;
import com.tangosol.net.CacheFactory;

public class MyDefaultFactory  extends DefaultFactory {

    public SessionHelper instantiateSessionHelper(ServletContext ctx) {
        CacheFactory.log(toString() + ": creating SessionHelper");
        azzert(ctx != null);
        azzert(getServletContext() == null && getSessionHelper() == null);
        String sJvmRoute = System.getProperty("jvmRoute", (String)ctx.getAttribute("coherence-jvmroute"));
        MyCookieHelper helper = new MyCookieHelper(this, ctx, sJvmRoute);
        setServletContext(ctx);
        setSessionHelper(helper);
        return helper;
    }
}
----------------------------------------------------

5. Modify the web.xml.
<param-name>coherence-factory-class</param-name>
    <param-value>com.tangosol.coherence.servlet.weblogic103.MyDefaultFactory</param-value>

Steps for WebSphere

Basically steps are very similar with WebLogic part except helper classes.

1. java -jar webInstaller.jar SessionTest.war -inspect -server:WebSphere/6.x

2. Modify coherence-web.xml
    <param-name>coherence-session-cookie-domain</param-name>
    <param-value>.test.com</param-value>

<param-name>coherence-session-cookie-path</param-name>
    <param-value>/</param-value>

<param-name>coherence-servletcontext-clustered</param-name>
    <param-value>true</param-value>

    <param-name>coherence-enable-sessioncontext</param-name>
    <param-value>true</param-value>

<param-name>coherence-scopecontroller-class</param-name>
    <param-value>
       com.tangosol.coherence.servlet.AbstractHttpSessionCollection$GlobalScopeController
    </param-value>
<param-name>coherence-session-id-length</param-name>
    <param-value>32</param-value>

3. java -jar webInstaller.jar SessionTest.war -install

4. Insert those two classes(MyCookieHelper, MyDefaultFactory) into the SessionTest.war file.
----------------------------------------------------
package com.tangosol.coherence.servlet.websphere60;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import com.oracle.FileLogWriter;
import com.tangosol.net.CacheFactory;
import com.tangosol.net.cache.LocalCache;

public class MyCookieHelper extends com.tangosol.coherence.servlet.websphere60.CookieHelper {
protected static final char SUFFIX_SEPARATOR = 46;
private LocalCache m_cacheFailover;
private String m_sConfiguredJvmRoute;
private FileLogWriter fileWriter;
public MyCookieHelper(
com.tangosol.coherence.servlet.SessionHelper.Factory factory,
ServletContext ctx) {
this(factory, ctx, null);
}

public MyCookieHelper(
com.tangosol.coherence.servlet.SessionHelper.Factory factory,
ServletContext ctx, String sJvmRoute) {
super(factory, ctx);
fileWriter = new FileLogWriter();
m_cacheFailover = new LocalCache(128);
m_sConfiguredJvmRoute = sJvmRoute;
}

public String decodeCookie(HttpServletRequest req) {
String sSessionId = super.decodeCookie(req);
CacheFactory.log("before :" + sSessionId);
fileWriter.writeToFile("before :" + sSessionId);
// WebLogic Session
if (sSessionId != null) {
int ofSeparator = sSessionId.indexOf('!');
if (ofSeparator >= 0) {
String sServerSuffix = getWebLogicAffinitrySuffix();
String sSessionSuffix = sSessionId.substring(ofSeparator);
sSessionId = sSessionId.substring(0, ofSeparator);
if (!sSessionSuffix.equals(sServerSuffix))
m_cacheFailover.put(sSessionId, sSessionSuffix);
}
}

// WebSphere Session
if ((sSessionId != null) && (sSessionId.length() > 4) && (sSessionId.startsWith("0000"))) {
sSessionId = sSessionId.substring("0000".length());

int ofSeparator = sSessionId.indexOf(getWebSphereAffinitySuffix());
if (ofSeparator >= 0) {
String sServerSuffix = getWebSphereAffinitySuffix();
String sSessionSuffix = sSessionId.substring(ofSeparator);
sSessionId = sSessionId.substring(0, ofSeparator);

if (!sSessionSuffix.equals(sServerSuffix)) {
this.m_cacheFailover.put(sSessionId, sSessionSuffix);
}
}
}
CacheFactory.log("after :" + sSessionId);
fileWriter.writeToFile("before :" + sSessionId);
return sSessionId;
}

public String decodeUrl(HttpServletRequest request) {
String sSessionId = super.decodeUrl(request);
CacheFactory.log("before :" + sSessionId);
fileWriter.writeToFile("before :" + sSessionId);
if (sSessionId != null) {
int ofSeparator = sSessionId.indexOf('!');
if (ofSeparator >= 0)
sSessionId = sSessionId.substring(0, ofSeparator);
}
   if ((sSessionId != null) && (sSessionId.length() > 4) && (sSessionId.startsWith("0000")))
   {
     sSessionId = sSessionId.substring("0000".length());

     int ofSeparator = sSessionId.indexOf(getWebSphereAffinitySuffix());
     if (ofSeparator >= 0)
     {
       sSessionId = sSessionId.substring(0, ofSeparator);
     }
   }
   CacheFactory.log("after :" + sSessionId);
   fileWriter.writeToFile("before :" + sSessionId);
return sSessionId;
}

public String getWebSphereAffinitySuffix() {
return ":";
}

public String getWebLogicAffinitrySuffix() {
return "!";
}
}
----------------------------------------------------
package com.tangosol.coherence.servlet.websphere60;

import javax.servlet.ServletContext;

import com.tangosol.coherence.servlet.SessionHelper;
import com.tangosol.coherence.servlet.websphere60.DefaultFactory;
import com.tangosol.coherence.servlet.websphere60.MyCookieHelper;
import com.tangosol.net.CacheFactory;

public class MyDefaultFactory   extends com.tangosol.coherence.servlet.websphere60.DefaultFactory {
public MyDefaultFactory() {
}
    public SessionHelper instantiateSessionHelper(ServletContext ctx) {
        CacheFactory.log(toString() + ": creating SessionHelper");
        azzert(ctx != null);
        azzert(getServletContext() == null && getSessionHelper() == null);
        String sJvmRoute = System.getProperty("jvmRoute", (String)ctx.getAttribute("coherence-tomcat-jvmroute"));
        MyCookieHelper helper = new MyCookieHelper(this, ctx, sJvmRoute);
        setServletContext(ctx);
        setSessionHelper(helper);
        return helper;
    }
}
----------------------------------------------------

5. Modify the web.xml. 
    <param-name>coherence-factory-class</param-name>
    <param-value>com.tangosol.coherence.servlet.websphere60.MyDefaultFactory</param-value>


Sunday Sep 18, 2011

Accessing Coherence Cluster Using Spring Bean on SOA SUITE 11g

Following solution was tested on SOA SUITE 11.1.1.4 with Coherence 3.6.0. There might be other way like below to access coherence cluster from SOA SUITE.

https://forums.oracle.com/forums/thread.jspa?threadID=2268739&tstart=180

Background:

Coherence cache-config is pre-defined for SOA Cluster, and all SOA composite application will inherit this. This cache-config is zipped in fabric-runtime.jar as name of soa-coherence-cache-config.xml(This can be observed with logs from clustered managed server) And tangosol-coherence-override.xml is also included in fabric-runtime.jar and enforce SOA server to use cache-config included in fabric-runtime.jar(As a result, -Dtangosol.coherence.cacheconfig in setDomainEnv cannot precede this)

I've tried out several options to make the whole thing work and this is what I found relatively cleaner solution than others. I will use Coherence*Extend and Spring Bean in SOA SUITE 11g.

Steps:

1. Extract tangosol-coherence-override.xml and soa-coherence-cache-config.xml from fabric-runtime.jar($WLS_HOME/Oracle_SOA1/soa/modules/oracle.soa.fabric_11.1.1/fabric-runtime.jar)

Edit  the tangosol-coherence-override.xml file.

CHANGE the cache-config param to locate your own cache-conifg file. This have to be created based on the soa-coherence-cache-config.xml included in fabric-runtime.jar. THIS FILE WILL BE USED IN STEP 2.

 Add the remote-scheme in the soa-coherence-cache-config.xml file.

2. Go to SOA Domain HOME, and modify setDomainEnv.sh. SET -Dtangosol.coherence.override to the file we extracted and modified in step1.

3. Configure Coherence Cluster to have TCP*Extend proxy. (This is simple enough, so omitted for brevity)

4. We will use Spring Bean instead of Java Embedding for coding convenience. In SOA project, create one interface and one class. as below.

5. Drag&Drop Spring Context from Component Palette to Composite Diagram, Select 'Create New Context' to create new spring bean context file.Open up newly created file.

 And drag&drop "Service" from right pane. After you add Service, bean definition will be created.

6. Wire BPEL(or Mediator) to Spring Context and Implement it appropriately(Add 'ASSIGN' and 'INVOKE')

7. It's all set to go now. Just one more trivial thing to do is, add 'wlfullclient.jar' and 'jps-internal.jar' into CLASSPATH of Coherence cache servers, so it won't complaint about "ClassNotFound"

 There might be more nicer way than this. I'll be looking for it.

Monday Sep 28, 2009

Creating domain only for ADF with SOA 11g

For whom are interested in playing with ADF and already got SOA11g installed, it would be good to have test ballpark only for ADF (excluding all SOA related components).

here is very good pointer for the people like me.

http://blogs.oracle.com/olaf/2009/04/upgrading_your_weblogic_to_adf_3.html

Start the step from No 5.

Good Luck!!

---- post edit
if you come across the weird ClassNotFoundException during your deployment from jdev,
put adfm.jar, adfmweb.jar, adfdt_common.jar, bc4j-mbeans.jar into ${domain_home$}/lib.

after restart the server, it should be fine. I gotta find the elegant way to handle this issue.

reference : http://forums.oracle.com/forums/thread.jspa?messageID=3379961
http://one-size-doesnt-fit-all.blogspot.com/2009/01/configuring-weblogic-server.html

About

Solution & Technology Architect, Asia Pacific

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today