Show me the code! – By Davanum Srinivas

December 21, 2009

Book on IBM WebSphere eXtreme Scale 6

Filed under: Uncategorized — Tags: , , , — Davanum Srinivas @ 10:29 am

The Packt folks have a new book out on IBM WebSphere eXtreme Scale 6

There’s a sample chapter available for free download as well – The DataGrid API

PS: Thanks to Ryan for sending me a copy of this book.

December 4, 2009

Android – Video/Music player sample (Take #2)

Filed under: Uncategorized — Davanum Srinivas @ 12:55 am

NOTE: Since many folks were looking for it…Here’s the updated version of code originally posted here

Here is a screen shot.

x

Notes



  • You can specify a directory path or a remote URL in the edit box

  • Choose any 3gp file from http://daily3gp.com/ to view videos

  • The 4 buttons are for play, pause, reset and stop

  • When you specify a http or https url, we save the url contents to hard disk first and then play it

  • The icons are from here

Here’s the code

/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.android.media;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.URLUtil;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Toast;
import android.widget.VideoView;

public class VideoViewDemo extends Activity {
	private static final String TAG = "VideoViewDemo";

	private VideoView mVideoView;
	private EditText mPath;
	private ImageButton mPlay;
	private ImageButton mPause;
	private ImageButton mReset;
	private ImageButton mStop;
	private String current;

	@Override
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		setContentView(R.layout.main);
		mVideoView = (VideoView) findViewById(R.id.surface_view);

		mPath = (EditText) findViewById(R.id.path);
		mPath.setText("http://daily3gp.com/vids/747.3gp");

		mPlay = (ImageButton) findViewById(R.id.play);
		mPause = (ImageButton) findViewById(R.id.pause);
		mReset = (ImageButton) findViewById(R.id.reset);
		mStop = (ImageButton) findViewById(R.id.stop);

		mPlay.setOnClickListener(new OnClickListener() {
			public void onClick(View view) {
				playVideo();
			}
		});
		mPause.setOnClickListener(new OnClickListener() {
			public void onClick(View view) {
				if (mVideoView != null) {
					mVideoView.pause();
				}
			}
		});
		mReset.setOnClickListener(new OnClickListener() {
			public void onClick(View view) {
				if (mVideoView != null) {
					mVideoView.seekTo(0);
				}
			}
		});
		mStop.setOnClickListener(new OnClickListener() {
			public void onClick(View view) {
				if (mVideoView != null) {
					current = null;
					mVideoView.stopPlayback();
				}
			}
		});
		runOnUiThread(new Runnable(){
			public void run() {
				playVideo();
				
			}
			
		});
	}

	private void playVideo() {
		try {
			final String path = mPath.getText().toString();
			Log.v(TAG, "path: " + path);
			if (path == null || path.length() == 0) {
				Toast.makeText(VideoViewDemo.this, "File URL/path is empty",
						Toast.LENGTH_LONG).show();

			} else {
				// If the path has not changed, just start the media player
				if (path.equals(current) && mVideoView != null) {
					mVideoView.start();
					mVideoView.requestFocus();
					return;
				}
				current = path;
				mVideoView.setVideoPath(getDataSource(path));
				mVideoView.start();
				mVideoView.requestFocus();

			}
		} catch (Exception e) {
			Log.e(TAG, "error: " + e.getMessage(), e);
			if (mVideoView != null) {
				mVideoView.stopPlayback();
			}
		}
	}

	private String getDataSource(String path) throws IOException {
		if (!URLUtil.isNetworkUrl(path)) {
			return path;
		} else {
			URL url = new URL(path);
			URLConnection cn = url.openConnection();
			cn.connect();
			InputStream stream = cn.getInputStream();
			if (stream == null)
				throw new RuntimeException("stream is null");
			File temp = File.createTempFile("mediaplayertmp", "dat");
			temp.deleteOnExit();
			String tempPath = temp.getAbsolutePath();
			FileOutputStream out = new FileOutputStream(temp);
			byte buf[] = new byte[128];
			do {
				int numread = stream.read(buf);
				if (numread <= 0)
					break;
				out.write(buf, 0, numread);
			} while (true);
			try {
				stream.close();
			} catch (IOException ex) {
				Log.e(TAG, "error: " + ex.getMessage(), ex);
			}
			return tempPath;
		}
	}
}

Download Source and APK from here – VideoView.zip

November 20, 2009

Debug code running on IBM Websphere using Eclipse / Intellij IDEA

Filed under: Uncategorized — Davanum Srinivas @ 1:39 pm

NOTE: Please back up the files before you modify them.

Step #1 : Edit the server.xml (for example $WAS_HOME/profiles/AppSrv01/config/cells/AppSrv01/nodes/AppSrv01/servers/server1/server.xml). Find the processDefinitions element and look for the jvmEntries under it. A typical entry looks like this:

  <processDefinitions xmi:type="processexec:JavaProcessDef" 
		      xmi:id="JavaProcessDef_1183122130078" 
                      workingDirectory="${USER_INSTALL_ROOT}" 
                      executableTargetKind="JAVA_CLASS" 
                      executableTarget="com.ibm.ws.runtime.WsServer">
    <execution xmi:id="ProcessExecution_1183122130078" 
               processPriority="20" 
               runAsUser="" 
               runAsGroup=""/>
    <ioRedirect xmi:id="OutputRedirect_1183122130078" 
		stdoutFilename="${SERVER_LOG_ROOT}/native_stdout.log" 
		stderrFilename="${SERVER_LOG_ROOT}/native_stderr.log"/>
    <monitoringPolicy xmi:id="MonitoringPolicy_1183122130078" 
		maximumStartupAttempts="3" pingInterval="60" 
		pingTimeout="300" autoRestart="true" 
		nodeRestartState="STOPPED"/>
    <jvmEntries xmi:id="JavaVirtualMachine_1183122130078" 
		verboseModeClass="false" 
		verboseModeGarbageCollection="false" 
		verboseModeJNI="false" runHProf="false" 
		hprofArguments="" 
		debugMode="false" 
		debugArgs="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=7777" 
		genericJvmArguments="">
      <systemProperties xmi:id="Property_1" name="com.ibm.security.jgss.debug" value="off" required="false"/>
      <systemProperties xmi:id="Property_2" name="com.ibm.security.krb5.Krb5Debug" value="off" required="false"/>
    </jvmEntries>
  </processDefinitions>

Step #2: Do you see the debugMode in the jvmEntries section? switch it from false to true and save the file.

debugMode="true" 

Step #3: Restart the server as usual using say the command line

root@dims-desktop:/opt/WAS70/profiles/AppSrv01/bin# ./startServer.sh server1
ADMU0116I: Tool information is being logged in file
           /opt/WAS70/profiles/AppSrv01/logs/server1/startServer.log
ADMU0128I: Starting tool with the AppSrv01 profile
ADMU3100I: Reading configuration for server: server1
ADMU3200I: Server launched. Waiting for initialization status.
ADMU3000I: Server server1 open for e-business; process id is 6913

Step #4: Using latest IntelliJ or Eclipse, you can use Remote debugging to attach to the running Websphere server. Please specify the same port (“7777″ in example above) as mentioned in the server.xml. Here are screen shots from Eclipse and Intellij on how to set up the debug configuration.





Step #5: Use the debug configuration created in the previous step, set up break points in your application and attach to the running Websphere process.





That’s it!

November 6, 2009

Better RSS feed for IBM WebSphere Application Server forum

Filed under: Uncategorized — Davanum Srinivas @ 6:21 pm

The websphere forum (see below) feeds are truncated
http://www.ibm.com/developerworks/forums/forum.jspa?forumID=266&start=0

You need to add “&Full=true” to get all the content as shown below:
http://www.ibm.com/developerworks/forums/rss/rssmessages.jspa?forumID=266&Full=true

October 27, 2009

WebSphere Application Server V7.0 top new features

Filed under: Uncategorized — Tags: , — Davanum Srinivas @ 8:51 am

Can’t believe it’s been one year since v7 was released! Andrew has a writeup here:

http://webspherecommunity.blogspot.com/2009/10/websphere-application-server-v70-new.html

August 27, 2009

[ANNOUNCEMENT] Apache Wink 0.1 Released (JAX-RS Implementation)

Filed under: Uncategorized — Davanum Srinivas @ 5:55 am

The Apache Wink team is proud to announce the availability of Apache Wink 0.1

Apache Wink is a framework for building RESTful Web services.
It is comprised of a Server module and a Client module for developing
and consuming RESTful Web services.

Disclaimer: Apache Wink is an effort undergoing incubation at The
Apache Software Foundation (ASF), sponsored by the Incubator PMC.
Incubation is required of all newly accepted projects until a further
review indicates that the infrastructure, communications, and decision
making process have stabilized in a manner consistent with other
successful ASF projects. While incubation status is not necessarily a
reflection of the completeness or stability of the code, it does
indicate that the project has yet to be fully endorsed by the ASF.

The Wink distribution is available at
http://www.apache.org/dyn/closer.cgi/incubator/wink/0.1-incubating/

The Wink web site is available at
http://incubator.apache.org/wink/

The Wink 0.1 source code repository is available at
http://svn.apache.org/repos/asf/incubator/wink/tags/wink-0.1-incubating/

For questions, please contact the Wink developers mailing list at
wink-dev@incubator.apache.org
To subscribe to the wink-dev@ mailing list, send an email to
wink-dev-subsribe@incubator.apache.org

You can also use Wink users mailing list if you are not interested in
developers information (e.g. JIRA issues, commits etc.)
wink-user@incubator.apache.org
To subscribe to the wink-user@ mailing list, send an email to
wink-user-subsribe@incubator.apache.org

Enjoy,
-The Wink team

August 25, 2009

Developerworks space for Websphere webservices team

Filed under: Uncategorized — Tags: , — Davanum Srinivas @ 8:35 am

We just got this going…with links to redbooks, technotes, articles etc here:
http://www.ibm.com/developerworks/spaces/ws

July 23, 2009

Websphere vs JBoss

Filed under: Uncategorized — Davanum Srinivas @ 1:38 pm

I tweeted this a couple of weeks ago…Now it looks like they have added a few more in the videos in the series that discusses the benefits of IBM WebSphere Application Server (WAS) V7 over JBoss AS 5.

June 19, 2009

*Free* IBM WebSphere Application Server for Developers

Filed under: Uncategorized — Davanum Srinivas @ 2:33 pm

Download for development and testing from here. Forums for help are here.

May 13, 2009

IMPACT 2009 – Presentatation on Web Services In WebSphereApplication Server V 7.0

Filed under: Uncategorized — Davanum Srinivas @ 8:25 am

Good overview from Henry Chung :
Web Services In WebSphereApplication Server V 7.0

« Newer PostsOlder Posts »

The Shocking Blue Green Theme Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 131 other followers