Cinco de Mayo @ JavaOne

Monday, May 5. 2008


May 4th

Arrived in San Francisco after a smooth flight, this flight is so quick from So Cal, you get a little reading in and before you know it you're on the ground again. Grabbed a shuttle to the hotel, Serrano Hotel, got my room and headed out for a little stroll to find some grub before I get an early start on Monday. TAD's S.F.Grabbed a tuna melt at TAD's which is a few blocks away. Never been, food wasn't bad and they seemed to have a big breakfast menu. Considerably cheaper than the Ponzu

which is running about 30.00 a meal (maybe I'll check it out before I leave). 

I must say, there is something about San Francisco, cool air hitting your face, homeless asking for money every corner, street musicians playing saxophone/guitar and what else they have, Musicianscable cars going by, people on the move, that's really enjoyable. Every time I come here, there is some real character to this place that is like no other place I've been. Quite nice to walk the streets, to see the hustle and bussel moving through the streets being apart of it for a week is a nice change. The weather is cool jacket weather that feels great from the heat of the south lately.

After my walk, I headed back to the hotel, prepared myself for the day to come, set the alarm and hit the hay.

May 5th - Cinco de Mayo

Got up at the break of dawn, 6:10 am (that's early for me), headed over to Moscone North, grabbed my registration and went to the lower level to pick up my materials for the conference. It's been since 2004 since I've visited Moscone and JavaOne, it looks similar to previous years, it always looked good and ready to deliver. This year is no exception. I guess I was so anxious to get over to the center and get my learn on that I had about two hours before my first Session, Developing Enterprise Applications with the Spring Framework, with two backpacks in tow I headed back to the hotel to drop some of this mess off.

Headed back, I grab a coffee and a piece of Banana Nut Bread from Starbucks, then it's over to the Intercontinental Hotel (Nice hotel) for the session.

Spring Framework by Chris Richardson

Since I've used Spring Framework with uPortal and some of the other projects at work, the first half of this session was simply a reminder of configuration possibilities and reasons why to use the framework, like the removal of DRY (Don't Repeat Yourself) code, easy testing with Mock Objects (Chris used JMock 2), removal of dependancies. Chris also covered xml configuration and annotation based configuration, even covered Java Config for configuring Spring. I guess I must have skipped the Bean Scopes somewhere along the way because Chris' explanation of them eye opening, kind of woke me up (hey you know you can do this?)

Bean Scopes

Singleton

  • The default and most common
  • Only create a single instance
  • Use for stateless beans

Prototype

  • Create a new instance each time you need one
  • When its injected or requested by getBean()
  • Use for stateful beans

 
Request and Session

  • Use in web applications for request/session-specfic state
  • The bean lives for the lifetime of request or session
  • Referencing beans are injected with a proxy



Next, he
covered Transactional Services in Spring. Transactional services offered by
Spring simplify user’s code by removing the repeated code. Spring allows you to
write metadata to create transactional POJOs. Via the help of Aspect Oriented
Programming (AOP) and Spring your code can be greatly reduced. Before I get
into the Spring AOP I’d like to cover a few AOP basics.



AOP Basics



Joinpoint



● Well-defined point during the execution of your application



● You can insert additional logic at Joinpoint's



● Examples of Jointpoint's



– Method invocation



– Class initialization

– Object initialization



Advice



● The code that is executed at a particular joinpoint



● Types of Advice



– before advice, which excutes before joinpoint



– after advice, which executes after joinpoint

– around advice, which executes around joinpoint



 



Pointcuts



● A collection of joinpoints that you use to define when advice
should be executed



● By creating pointcuts, you gain fine-grained control over how
you apply advice to the components



● Example



– A typical joinpoint is a method invocation.



– A typical pointcut is a collection of all method invocations in
a particular class



● Pointcuts can be composed in complex relationships to further
constrain when advice is executed






Aspects



● An aspect is the combination of advice and pointcuts



 



 



For more on Spring AOP see
http://www.javapassion.com/j2ee/springaopbasics.pdf.



 



Spring wraps objects with
proxies that can execute extra advice before method invocation, after invoking
a method, or instead of a method. Transactions are managed through TransactionInterceptor.
This class manages transactions and intercepts method calls then delegates to
the PlatformTransactionManager.



 



By wrapping objects, your
components are unaware of the transactional code that is executed when your
object interact with other objects what are using Spring’s AOP Transaction
Management. Management is configured through an xml
configuration
or via Spring Annotations. Check out
<context:annotation-config/>
for
annotation
configuration
.



 
Spring allows programmers to remove tightly coupled, duplicated and tangled code with code that is easier to maintain, test, and develop.
  Chris did a good job of explain how Spring can help. The AOP/Transaction management was a real eye opener and features that I don’t currently use. The dependency injection part of spring has been something I’ve been using for quite some time. I’m not going to cover every aspect of the session but I’ve tried to highlight some of the key points that Chris when over in the session. Additional projects that Chris is involved with are:
 
http://code.google.com/p/aop-ood
http://code.google.com/p/projecttrack
http://code.google.com/p/aridpojos
http://code.google.com/p/ormunit
http://code.google.com/p/umangite
http://code.google.com/p/cloudtools
 


 



Web 2.0 Leveraging the Project jMaki and Google Web Toolkits for
Rapid Website Development



 



jMaki



 



This session started with
Evan Troyka discussing jMaki. jMaki is
a wrapper for different ajax libraries like dojo and Yahoo ui. jMaki uses jsp
tags, JSF components, php libraries, and phobos implementations for different
deployments. A jMaki component consists of three different files, component.js,
component.htm, and a component.css. An optional file is the config.json. This
is a central location for configuration of javascript libraries, API keys, CSS
dependencies, jmaki Glue handler mappings, mapping extensions, and theme
information. jMaki glue lets you wire together jMaki widgets via a
publish/subscribe event model. This was interesting to see how you can use
different components from ajax libraries via one technology like JSF or JSP tags.
Some additional information on jMaki can be found at:



 



http://forums.java.net/jive/forum.jspa?forumID=96



http://weblogs.java.net/blog/carlavmott



http://weblogs.java.net/blog/gmurray71



http://weblogs.java.net/blog/arungupta



 





GWT



 



The real value (for me) in
this session was the second half where David Geary went over GWT Toolkit. I’ve messed with
this a little but I haven’t really dug into the project much. Wow was this
helpful to see the possibilities with GWT. GWT is a java library that allows
you to compile Swing like code into JavaScript. This eliminates the need to
test code for cross browser compatibility or learn JavaScript altogether. Some
of the features of GWT:



 



·        
Debug client-side UI in Java code



·        
Make remote method calls to a servlet



·        
Incorporate Javascript with native methods



·        
Use widgets and implement new ones



·        
Use the browser history mechanism



·        
Integration with JUnit



·        
Internationalization



 



More on GWT later. You can
also look at http://cooland usefulgwt.com.



I’ve been trying finish
this damn entry the last two days, there was just so much information at
JavaOne, it make it difficult to cover all that was there. To think I’m still
on Monday, Java University, before the conference session really started.



 



Really today was jammed with
material, each session was 3 hours long and we stopped after 8pm. I was toast,
tons of information and it's only the beginning. I really hope to finish the
blog but I'd like to get some sleep for tomorrow is another day of learning.



Really today was jammed with material, each session was 3 hours long and we stopped after 8pm. I was toast, tons of information and it's only the beginning. I really hope to finish the blog but I'd like to get some sleep for tomorrow is another day of learning.

JavaOne - May 5 - May 9th

Friday, May 2. 2008


JavaOne 2008

JavaOne 2008Without actually thinking anyone would read this, I've been trying to spend a little more time writing in my blog. But work and life in general seem to get in the way.

Good News is on the horizon! I'm about to close on a new home with my squeeze, Lisa, and I'm off to JavaOne this week. I know, can't get much better than that! It's been since 05, the last time I went to San Fran to visit Duke and the city by the bay, so I'm going to try to make the most of it. Major changes to Java and other languages based on the JVM have arrived so the goal is to check some of those languages out (Grails, JRuby). Also I want to get more information on JSR 296. I've started a development in that area and I'm curious to see what is going on with that. I will for sure check out some Spring session as it's moving to 2.5 release, so I'm sure there is valuable information there. As I'll need that because I've been messing with the new Spring Web Flow 2.0.0 RC1 release. I also have a session on jMaki, not to sure what to expect, but it should be interesting as I haven't been messing much with the Ajax stuff, so this seem like a good time to check it out of some hot clam chowder. Other notables are a session on JXTA which I haven't seen nor heard much from in years (I did my thesis using this technology). I'm quite interested to see if anything changed there (Wait as I'm getting the link, I see there is a new version 2.5 that has been released in November 07).

So as I prepare for my trip, I'm looking forward to all the information I can cram into my brain for the week and feel comfortable knowing that all the paperwork is in place for the new pad, for when I return, we can have a smooth transition from our current location to the new one. (Let's hope these damn gas prices give)

MAVEN DEPENDENCIES

Thursday, April 17. 2008

MAVEN DEPENDENCIES

Dependency scope is used to limit the transitivity of a depedency, and also
to affect the classpath used for various build tasks.


There are 5 scopes available:


  • compile
    This is the default scope, used if none is specified.
    Compile dependencies are available in all classpaths of a project. Furthermore,
    those dependencies are propagated to dependent projects.
  • provided
    This is much like compile , but indicates you
    expect the JDK or a container to provide the dependency at runtime. For example,
    when building a web application for the Java Enterprise Edition, you would set
    the dependency on the Servlet API and related Java EE APIs to scope
    provided because the web container provides those classes. This scope
    is only available on the compilation and test classpath, and is not transitive.
  • runtime
    This scope indicates that the dependency is not required
    for compilation, but is for execution. It is in the runtime and test classpaths,
    but not the compile classpath.
  • test
    This scope indicates that the dependency is not required for
    normal use of the application, and is only available for the test compilation
    and execution phases.
  • system
    This scope is similar to provided except that you
    have to provide the JAR which contains it explicitly. The artifact is always
    available and is not looked up in a repository.
  • import
    This scope is only used on a dependency of type
    pom in the <dependencyManagement> section. It indicates
    that the specified POM should be replaced with the dependencies in that POM's
    <dependencyManagement> section. Since they are replaced,
    dependencies with a scope of import do not actually participate in
    limiting the transitivity of a dependency.
For more

iPhone Totally Rocks

Wednesday, April 16. 2008

Ok after years of procrastination, I've finally broken down and gotten a new phone, but not just any phone, I got an iPhone. After hearing all the hype and the expense I've fought the urge the purchase a new phone for some time. My previous phone was the Treo 650. Now I guess this phone serviced its purpose, but the interface had issues and I could never really tell how many voice messages were in my inbox without calling. The internet of the phone, was pretty much unusable.

Now for the iPhone, this thing is cool. Really cool! I can tell when people call, leave voicemail, sms, and the internet with the 802.11b/g capability, forget it! This thing rocks! I didn't think one little device would be so much help and distraction all in one little package. I mean I really don't spend that much time away from the computer, and now with this little device, its really difficult to not take it to lunch and dinner and read what's up in the world wide web.

I'd really like to write some code for this thing, but I don't own a mac, but this thing may just cause me to breakdown an purchase yet another Apple product.



Luminis IV & uPortal

Wednesday, April 16. 2008

Random Note:

Luminis IV is built on top of uPortal 2.5.3.


Log Time No Post

Tuesday, April 15. 2008

ForFiles

Just a quick note to self, deleting Apache files older than 60 days:

forfiles /p f:\Apache\Apache\logs\ /s /m ssl.log /d -60 /c "cmd /c del @file"

Oh yeah! Blog more often!

uPortal 2.6.0

Friday, August 24. 2007


Quick Notes for me:

Tidy.jar has dom implementations that must be removed. These class file conflict with the dom implementation that is in JDK 1.6. Quick fix to remove the org.w3c.dom class files from the tidy.jar.

xml-apis.jar must be removed as well for the same reason.

CAS Setup Information

Testing remember to generate a cert with name localhost.


http://www.ja-sig.org/wiki/display/UPM/01+CAS+Authentication+for+the+Impatient

SSL Issues

Proxy Validation Issues

SD West 2007 - Random Notes

Tuesday, March 27. 2007


March 21, 2007 – Day One
Session 1: Effective Aspect-Oriented Programming – Ron Bodkin

rbodkin@newaspects.com
http://www.eclipse.org/aspectj

Eclipse with AspectJ Plugin or Spring AOP or JBoss also have tools for eclipse as well.

Pointcut defines the join point where we want to call the aspect.

public aspect MeteringPolicy {

pointcut useTitle() :

execution(public void Song.play()) ||
execution(public void Song.showLyrics());

after() returning : useTitle() {
MeteringService.trackUse();

}

}

Terms: advice method (do the following thing), pointcut
ajc links the aspects to the java objects. You need to use ajc at some point to grab the pointcuts in the java code. However, Spring will use proxies that are called instead of requiring the use of ajc (aspects compiler) to modify the bytecode.

Used for tracing, monitoring, handling boiler plate code, used for understanding your system better.
Example:

call(* Remote+.*(..) throws RemoteException);

This example can be used to handle all the RemoteExceptions so the programmer doesn’t have to write the code to handle RemoteExceptions. This removes the boiler plate code of the try/catch in every call that throws a RemoteException.

Advice: Start small, only a few should write the aspects. Incremental adoption works best

Random Notes:
AspectJ 5 (latest, most flexible)
Spring AOP – handles a subset of the JAspects advices handles
JBoss AOP
Check out Glassbox for performance monitoring and problems. Uses load time weaving.

Session2: Crystal Clear: A Human Powered Methodology for Small Teams – Alistair Cockburn

Talk about agile coming out well or not well. What’s the difference?

Crystal Clear – Questions
Small teams hasn’t been working well…

Nothing written down
specs not clear
more changes than people can do
resource-starved project … req’ts /it infrastru /

Techniques for getting max benefit from limited resources
Guidelines to use agile
When Customer/sponsor

Successful projects where listening to the people (people-centric) and constantly modify the methodology.

Different people do different things. Can’t drive a methodology down someone’s throat. Different projects and people use different methods (pair programming, uml design, test driven development, etc). happy people ship, happy code! People like to be told what to do, so they won’t do it. Each person has to say what they are going to do.

Crystal’s purpose: Keep people from hurting each other, keeping each other informed
Crystal’s nature: A set of conventions that get updated

Six people or less. Give them a whiteboard, let them ship code, and you’re almost done.

Thinks of each project as a game.
Primary Goal: Deliver the project
Secondary Goal:

From the seven principles of methodology design
Face-to-face communication is the cheapest and fastest channel for exchanging information

Recommended Reading
The Goal (Paperback)
by
Eliyahu M. Goldratt (Author), Jeff Cox (Author)

Frequent Delivery
Osmotic Communication – no private offices, communication is easy
Reflective Improvement – What are we doing, how are we doing it. How do we improve.

Personal Safety
Focus – don’t work on two or more projects
Easy Access to Expert Users
Technical Environment with (agile places this first, that’s ok)
Frequent integration
Automated testing
Config management

Critical technique in Crystal: Slide 20 Reflection Workshop. Discuss and determine what things you’re going to try. Try these are things you can control and do.

Sets projects based on color. Clear, Orange, Yellow, etc.

Session 3: An Overview of TR1 – Scott Meyers

smeyers@aristeia.com
http://www.aristeia.com

Technical Report 1 – Future standard of functionality to be in standard C++

Currently in the std::tr1 eventually maybe in the std namespace. You must have a TR1 conformant library for this to work.

New Functionality: C99 Compatibility

TR1 is a specification. This is an interface specification not an implementation. To understand the functionality in TR1: http://www.aristeia.com/EC3E/TR1_info.html

10 of the 14 libraries in TR1 are modeled on Boost libraries. Boost will bring its libraries into conformance with TR1.

gcc 4.0 – has some of the TR1. To get it, you can use Boost library, it has 11 of the 14. You can also look at Dinkumware.

Smart pointers declared in the header <memory>. Check out auto_ptr and shared_ptr. “this” is a raw pointer. Be careful when returning shared pointers to yourself.

Operators: static_pointer_cast, dynamic_pointer_cast, const_pointer_cast
Relational: ==, !=, <

Output: <<

auto_ptr solves the problem of exclusive ownship. shared_ptr solves the problem of shared ownship. auto_ptr always deletes its resource.

tr1::weak_ptrs can’t keep resources alive. Solve the problem of dangling pointers and cyclic references.

TR1 tells you nothing about where these features are thread safe.

HashTables

Regular Expressions
declared <regex>

Pete Becker’s Book on TR1. Slide page 54.

Session4: Puzzlers

Review the slides…

Examine - Autoboxing, varargs, generics

March 23, 2007

Session1: What’s coming in Java6 – Jason Hunter

StaX – pull parse, doesn’t store the whole document in memory, good good.

Annotations
Thrid Party @Nullable, @notNull – IntelliJ
@Test, @Before, @After in JUnit 4
@Immutable, @ThreadSafe, @NotThreadSafe, @GuardedBy from Java Concurrency in Practice

Java 5 – apt (annotation processor tool)
Java 6 – (standardized) java –processor

Core HTTP Server
Mini-Servlets, in com.sun.net.httpserver. Designed to support JMX and JAX-RPC. Only used for their own purposes.

New Deque = Double Ended Queue
acts like a Queue + Stack
Navigable Sets and Maps, let’s you get near missed items. I’m looking for this, if its not there, give me the one right above it or the one right below it.

Randomized Skip Lists - http://en.wekepedia.org/wiki/Skip_list
A linked list capable of large forward jumps

Removing feature’s in Java 6
Aimed at reducing the Java Runtime jar. The first thing to remove is javax.sound.midi, it has a target.

Java 7
Just thinking about stuff right now.
JAM to JARS. Java Modules proposed in JSR 277
Use the metadata to discover, load, and check module
Also superpackages, package families, which has special rights to classes in the superpackage

Dynamic Languages – new invokedynmaic bytecode
JSR 292 would let you invoke methods in the absensce of static type information

NIO 2 – JSR 203
A new filesystem API
Asynchronous filesystem calls
Better tie socket channels and sockets
(Fuse) -
http://fuse.sourceforge.net/

Javadoc Update
More easily identify factory methods

Non-API features
Putting XML in as a standard data type
Strings in switch statements
Comparisons for enums
Closures?

http://java.sun.com/avase/6/docs/api
http://planetjdk.org
get slides @
jhunter@marklogic.com

Session2: Extreme Web Caching – Jason Hunter

javap -public -classpath jsse.jar java.lang.Class
Determines the public interface
Based on “HTTP Caching & Cache-Busting for Content Publishers by Michael Radwin

Client
GET /index.html HTTP/1.1
Host:
www.server.com

Server
HTTP/1.1 200 OK
Date: …
Last-Modified: …
Content-Length: 2750 (Good for keep alive, this helps the client know when it’s the client’s turn to talk again)
Connection: close
Content-Type: text/html

<html><head><title>

Side note: JSPs buffer 8K by default
expires tag means the jpg or whatever is still go until that date. If-Modified-Since revalidates that the content hasn’t changed. If the content hasn’t been modified the server returns status code 304, not-modified-since, but doesn’t return the content the user requested.

1. Use “Cache-Control: private” for personalized content

Issue with cookies, sending a cookie say from jane back to john. So you should use Cache-Control header. Cache-Control: private
Disallows shared caching, allows private (browser)

Cache-Control: public
Explicitly allows shared caching

2. Implement “Images Never Expire” policy

Dictate that images (icons, logos) once published never change

Set Expires header 10 years in the future

Check – http://use.perl.org/~geoff/journal/22049

3. Cookie-free TLD for Static

Use a separate domain for static content

A domain without cookies

www.server.com for html

static.server.net for images, PDFs, etc

4. Apache Defaults for CSS/JS

Rely on If-Modified-Since request header
No special configuration needed

How can a server know when servlet content changes?

The .class timestamp is meaningless

Help the ser with getLastModified()

public long getLastModified(HttpServletRequest req) {

Return datamodified.getTime();

}

Called before doGet(), possibly avoiding doGet()

5. Random URL strings

Add javascript to create random url

Point all the ad servers to localhost 127.0.0.1, this removes all the adds when browsinghttp://www.everythingisnt.com/hosts.html

http://www.mnot.net/cacheability/http://www.mnot.net/cache_docs/

http://www.radwin.org – he’s blog

Session3: Java Persistence API Overview – Cay Horstmann

San Jose State University
Influenced by Hibernate, Oracle TopLink, JDO
Annotation the fields in the class, not the getter and setter.

There are five requirements for an Entity
Annotated with @Entity
primary key
no-arg constructor

Persistence context = set of managed entities
Entity manager = object that manages persistence context (find, persist, createQuery, …)

Need the persistence.xml file.

Can’ persist inner classes and final classes

With eclipse wait for Dali and WTP.

Address issues of refactoring the objects. What happens if we change the foreign key relationship or we modify the way that relationship between entities are modified.

What happens with the cache? If we get a result from a query and then modify the table so we have a new entity. If I query again the cache returns the original result set before the insert. How do we get around this?

Away around naming objects like “User” this is a sql reserved word. However, Hibernate has a method of getting around this does JPA.

Java Persistence Query Language (JPQL)

Lazy Fetching
Fetching is eager by default for @OneToOne, @ManyToOne.

To use an EJB container or not? Use annotations to get EJBs and a handle on the EntityManager.

Session4: What’s New in XML in Java 5 and 6 – Elliotte Rusty Harold

JAXP
DOM 3
Java XPath API
Java Validation API
Java XML Digital Signature API
StAX

Java 5 added DOM Level 3 support
Remember, getTextContent() and setTextContent(String textContent) cuts dozens of lines out of programs.

User Data – a user-defined callback class that is invoked when a node is cloned, imported, etc.

Bootstrapping
DOM2 has no implementation-independent means to create a new Document object

DOMImplementation impl = DOMImplementationImpl.getDOMImplemenation();
Document fibonacci = impl.createDocument(…);

To read a document, must import

org.w3c.dom.ls.*;
org.w3c.dom.bootstrap.*;

Checkout LSParserFilter, org.w3c.dom.ls, for removing parts of the document when reading.

Writing LSSerializer serializer = implls.createLSSerializer();

LSOutput output = implls.createLSOutput();
…blah… blah

XPath
Query without detailed DOM navigation
eg. //book[author=”Neal Stephenson”]/title”
javax.xml.xpath package

Java Validation API
package javax.xml.validation
JDK bundles W3C schema support

http://www.cafeconleche.org/slides/sd2007west/java5xml/

BOF – Interviewing in Silicon Valley

http://www.techsmith.com
htdye@linkedin.com

paultima.blogspot.com

Interesting bit of information about interviewing for jobs in Silicon Valley, from Google perspective. Discussion included a log of emphasis on algorithms and Big O runtime for algorithms. How would you sort a collection of A, for example, why? Advice was to focus on some open source projects that are interesting. This helps when potential employers look at your resume they see that you’re interested in the community and making contributions to projects.

March 23, 2007
Session1: Everything New in ASP.NET 2.0 - Stanfield

This session was a complete waste of time. The speaker was fumbling around, finished early and started his next presentation on AJAX. In addition, the presentation is available online from Microsoft, so the session was completely unhelpful.

Session2: Using Visual C++ To Light Up on Windows Vista – Nikola Dubar

Microsoft is trying to make development on Vista easier for C++ developers. Includes WCF, and WPF. The demonstration utilizes Visual C++ Orcas. Second part of the talk will be improvements to MFC. Check the article, Top 10 Ways To Light Up.

Orcas is coming out pretty soon.

User Access Control
Reliability and manageability
Restart Manager – saves the application’s state, shuts the app down, updates the application code and restarts the application.

Application Recovery and Restart – register callback functions, if the app dies this function is called to restart the application.

Function Discovery – enables apps to discover and manage lists of devices or objects sorted by functionality or class. Available before but it is more organized now, a standardize method for retrieving this information.

Cancelable I/O –

Customer Feedback Loop

Windows Quality Online Service, register with ms and get your app dumps when they crash. The apis provide ability to customize reports for your dumps. Check this out!

Windows Vista style guidelines

New Common Item Dialogs
Windows Vista Wizard Framework – PSH_AEROWIZARD
Checkout comctl32.dll

WPF – Rich library of controls – core component of .NET 3.0
No native code alternative
WPF, WCF, XPF – is only available in managed code
MFC part is all native

Organize and Search
All mechanisms are exposed via COM interfaces

WCF – Windows Communication Foundation
Helps with evolving client app into service oriented applications
Single programming model
Part of .Net Framework
No native code alternative

Mix mode allows you to use native C++ and call the .NET framework for features that use .NET features through C++ CLI.

Three modes
–clr (native and managed)
-clrpure (all managed code)
-clr (verifiable code)

RSS library

Document data
XML-based document packaging
XPS

Additional libraries for Mobile Devices
Network Awareness APIs
Sync Center
Power Management
Window SlideShow

10 new features in Vista only 3 are managed code the others are native code

VC++ Orcas
UAC-ready
Base Address Randomization – prevents hacker for getting address of dll. Hacker has to guess where dlls are loaded.
Data Execution Protection doesn’t allow buffer overflow

JPA – possible app rss reader that persists content
Or java accessing the .net apis for rss feeds etc

Session4: How to Build a Scalable Multiplexed Serer With NIO – Ron Hitchens

ron.hitchens@marklogic.com
ron@ronsoft.com
http://javanio.info

How to use NIO to build a server. Lower level i/o that is more sufficient for io than the java.io package. Gives access to some of the lower features that the OS has for I/O.

Three ways for multiplexing in a server.
Poll each socket – not very good cause we have to check each socket for a request. If there’s one there process it. This could starve other processes

Thread-per-socket – this is how java worked before. Overhead of managing many threads.

Readiness selection (NIO)selects the sockets that are ready, requires OS and JAVA VM support

The Reactor Pattern – Google for Douglas Schmidt*

http://www.cs.wustl.edu/~schmidt/patterns-ace.html

From the UML PatternDemultiplexer – knows which sockets are ready. This is the object that answers that question.
Event on a handle is some data has arrived

NOTE: buffer bytes and reconstitute the structure. Structured messages will be fragmented across the network.

Handler can’t write directly to the socket. This is by design it should only read and write to queues. Handler checks the queue to see if it do something with data. If there isn’t enough data the handler replies back to the Dispatcher, I don’t have enough data. Once all the data is there, the handler will do its thing with it.

Old model is thread per socket, bad. This new model is one thread per message.

NIO Reactor UML – blue objects are part of the jdk

O’Reilly – Ray Lischner’s C++ in a Nutshell

Gradebook TODO:: What's Next?

Friday, December 1. 2006

Now I have a good portion of the Gradebook app working in uPortal. Next I need to add the export in Excel and CSV formats to the instructor view, but before I got that far, I'm going to  add data from a live course. I mean the course information with the roster. The student view needs to be tested and examined before I can do anything else. Once I have the course and students loaded I'll return to export features, then I should be ready for demo day... Just wanted to write a quick note to myself, so I remember where I'm at on this. It took me all week to get to work on this, so I didn't want to forget my train of thought.

If I get the chance, I'd like to start working on my course material for my C++ course. Well I better find some way to wind down so that I can start another day tomorrow.


Gradebook Portlet URL Errors

Friday, December 1. 2006


Now that I have the application (Sakai Gradebook) working as a portlet, I had to modify a few more things that the portlet framework didn't like.

1) I was receiving Portlet Exceptions on resources. assignmentDetails.jsp and courseGradeDetails.jsp were receiving exceptions when trying to retrieve the dhtmlpopup.css and the dhtmlphpup.js. The jsps use relative links to reference these files. I had to add the portlet context to the references to stop the exception from being thrown.

org.apache.pluto.core.impl.PortletResponseImpl.encodeURL() checks for absolute urls. If the resource is reference via a relative url, a PortletException is thrown.

2) Beans defined in the ui project are defined with request scope. These beans had to be modified to use session scope. Since the request is split in an action request and a render request, when the jsps are being rendered, there aren't any request variables in scope. This is solved by changing the bean scope to session and using my RoleListener to handle removing the bean upon new requests. Example, when assignment details are requested for each homework assignment, upon the initial request a session bean is created say for homework #1. Now if we make a new request to view details of homework #2, the session bean exists from the initial request and homework #1 is displayed again. Thus the session bean needs to be removed to create a new bean with the data pertaining to homework #2. Again this works fine if we're using the application as a standalone application, but since the app has been pushed into a portlet framework, uportal, the requests don't work as designed.

3) The popup for gradebook logs doesn't show the close icon due to it being specified as a relative link. I've changed the the following line:

closeIconUrl="dhtmlpopup/dhtmlPopClose.gif"

to

closeIconUrl="${pageContext.request.contextPath}dhtmlpopup/dhtmlPopClose.gif"

in the gradingEventLogs.jspf file. I also modified the tag library descriptor, gb-jsp.tld, changing the rtexprvalue to true so that the attribute "closeIconUrl" accepts and evaluates the ${pageContext.request.contextPath} expression.

<attribute>
<name>closeIconUrl</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue></attribute>

Now the eventLogs popup shows correctly in the portal. One minor issue was that the popup was showing up lower than I liked so I removed the dhtmlGetPageYOffset() from the dhtmlPopupShow() function so that it displays the popup where the log image is clicked on (this is located in the dhtmlPopup.js).

4) **** Is another issue with the portlet getting the proper context for tags in the myfaces library. In the addAssignment.jsp, it uses the inputCalendar component. When this component is loaded it initialize the calendar. However, the component needs popcalendar_init.js and the popcalendar.js to initialize the calendar component. I assume that the issue is due to the application being in the portal context while trying to get the js files from that context and not the portlet context. I'll have to look into this later. However, a quick fix is to add the two js files to the js directory in the ui package in the Gradebook, then add references to the to files in the assignmentEditing.jspf file after the description text in the <h:panelGroup/> tag.

<f:verbatim><script src="${pageContext.request.contextPath}/js/popcalendar_init.js" type="text/javascript"></script><script src="${pageContext.request.contextPath}/js/popcalendar.js" type="text/javascript"></script></f:verbatim>

Integrating Sakai Gradebook in Uportal

Tuesday, November 7. 2006


As you may or may not know I've been trying to integrate Sakai's Gradebook applicaiton into uportal. I thought this may save some resources by not having to have a full implementation of Sakai in place to take advantage of the code that is available. Even if this is the end result of this whole exploration. At least I was able to get up close and personal with Sakai.

So to begin with I copied the standalone-app in the sakai gradebook src and decided to modify my code in a new directory instead of messing with the standalone app. Thus, I called the new directory, "uportal-app". Then I added a portlet.xml file containing the following:

<?xml version="1.0" encoding="UTF-8"?>
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
version="1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">

<portlet>
<description xml:lang="en">Gradebook Portlet</description>
<portlet-name>gradebook</portlet-name>
<display-name xml:lang="en">gradebook</display-name>

<portlet-class>org.apache.myfaces.portlet.MyFacesGenericPortlet</portlet-class>

<init-param>
<name>default-view</name>
<value>/index.jsp</value>
</init-param>
<expiration-cache>-1</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
<portlet-mode>help</portlet-mode>
</supports>
<portlet-info>
<title>gradebook</title>
<short-title>gradebook</short-title>
<keywords>portlet, gradebook</keywords>
</portlet-info>
</portlet>
<!-- Fullerton College Attributes -->
<user-attribute>
<description></description>
<name>username</name>
</user-attribute>
<user-attribute>
<description></description>
<name>displayName</name>
</user-attribute>
<user-attribute>
<description></description>
<name>uPortalTemplateUserName</name>
</user-attribute>
<user-attribute>
<description></description>
<name>memberOf</name>
</user-attribute>
</portlet-app>

There are two things to take note of here. One is the portlet-class which is located in the myfaces.jar that is provided in the application to begin with. The second is the index.jsp file which I provide for the instructors/students to choose which grade/gradebook they want to work with first (more on this later). The standalone application has an index.htm file with essentially logs the user into the application. The html file won't work in the portlet beside the fact that if the user is seeing the gradebook application in uportal, they are already logged in.

Next, I had to add modifications to the web.xml file. Here I define a new servlet to respond to the portlet context:

<servlet>
<servlet-name>gradebook</servlet-name>
<servlet-class>org.apache.pluto.core.PortletServlet</servlet-class>
<init-param>
<param-name>portlet-class</param-name>
<param-value>org.apache.myfaces.portlet.MyFacesGenericPortlet</param-value>
</init-param>
<init-param>
<param-name>portlet-guid</param-name>
<param-value>sakai-gradebook-uportal-app.gradebook</param-value>
</init-param>
</servlet>

and the mapping to the servlet

<servlet-mapping>
<servlet-name>gradebook</servlet-name>
<url-pattern>/gradebook/*</url-pattern>
</servlet-mapping>

Issue 1

Once the application is built, the index.jsp should respond. However, the Filters that are defined in the web.xml no longer work when the application is converted to a portlet. AuthnFilter and AuthzFilter will not be called from the normal execution of the portlet. These filters are defined in the following classes:

org.sakaiproject.tool.gradebook.ui.standalone.AuthnFilter
org.sakaiproject.tool.gradebook.ui.RoleFilter

The workaround

I defined two PhaseListener classes which provided similar functionality to the two filters: org.sakaiproject.tool.gradebook.jsf.AuthnPhaseListener and org.sakaiproject.tool.gradebook.jsf.RolePhaseListener. I placed the code in the beforePhase() method for each of the classes. These classes provide authorization and authentication information. The RolePhaseListener determines if a users has the ability to do something with the gradebook. I'm going to assume that you are either a student or instructor and will at least have the ability to modify or see your grades. Thus I omitted the RolePhaseListener and am only utilized the AuthnPhaseListener at the moment.

To support the new AuthnPhaseListener and to provide user information from uportal instead of Sakai, I have added the following classes to the gradebook service app:

org.sakaiproject.tool.gradebook.facades.uportal2impl.AuthnUportal2Imp
org.sakaiproject.tool.gradebook.facades.uportal2impl.ContextManagementUportal2Impl

Then the uportal-app/src/webapp/WEB-INF/spring-facade.xml file was modified to utilitze these new classes as:

<!-- External Authz Service -->
<bean id="org_sakaiproject_tool_gradebook_facades_Authz"
class="org.sakaiproject.tool.gradebook.facades.sections.AuthzSectionsImpl">
<property name="sectionAwareness"><ref bean="org.sakaiproject.api.section.SectionAwareness"/></property>
<property name="authn"><ref bean="org_sakaiproject_tool_gradebook_facades_Authn"/></property>
</bean>

<!-- External ContextManagement Service -->
<bean id="org_sakaiproject_tool_gradebook_facades_ContextManagement"
class="org.sakaiproject.tool.gradebook.facades.uportal2impl.ContextManagementUportal2Impl">
</bean>


This replaces the standalone implementations and can now provide uportal specific information about the users.

Issue 2

If you now build and deploy the application you will receive a NoClassDefinitionFound in org.sakaiproject.jsf.app.SakaiVariableResolver at line 137. The class that isn't found is org.sakaiproject.component.cover.ComponentManager. The VariableResolver attempts to retrieve the WebApplicationContext from the ServletContext and then load a Bean the Spring Framework. If a reference to the WebApplicationContext can't be obtained, the VariableResolver attempts to load the Object from the Sakai Component Manager. This is all fine and well, however, since this a portlet in uportal the Component Manager doesn't exist nor can the WebApplicationContext be obtained from the ServletContext.

The workaround

I defined a new class, org.sakaiproject.jsf.app.UportalVariableResolver, that obtains the WebApplicationContext from the FacesContext and then attempts to load the Bean from the WebApplicationContext.

wac = FacesContextUtils.getRequiredWebApplicationContext(context);

instead of

wac = WebApplicationContextUtils.getWebApplicationContext((ServletContext) context.getExternalContext().getContext());

Now this code is not in the gradebook application, but is in the JSF app in Sakai. Once I added my new UportalVariableResolver, I have to configure it from the faces-config.xml located in the jsf/app/META-INF directory. Here I replace the SakaiVariableResolver with the new UportalVariableResolver and then bld the jar and install it into my Maven repository. Once that is complete I can rebuild my Gradebook application and it will place this new sakai-jsf.x.x.x.jar into my WEB-INF/lib directory and all is well again (Well not quite).

Sakai Gradebook App

Tuesday, October 17. 2006

Today I'm starting with a uportal-app directory which is a copy of the standalone-app directory. This way I can make changes and mistakes to the uportal-app without messing with the standalone-app. To speed up compile time I moved the standalone-app out of the gradebook directory altogether and will move it back once I'm done messing with the uportal-app.

I modified the maven.xml in the uportal-app directory to point to the appropriate directories in uportal-app instead of standalone-app. I.E.

<goal name="load-uportal">
    <j:set var="goal" value="load-full" />
    <j:set var="maven.multiproject.includes" value="app/uportal-app/project.xml" />
    <attainGoal name="multiproject:goal" />
</goal>

So now each goal in the uportal-app/maven.xml file points to the project.xml in that directory. Now to build the application I need to use:

maven -Duportal_standalone=true -Dmaven.test.skip=true cln bld

In addition to the changes in the maven.xml file I also added a portlet.xml file to the uportal-app/WEB-INF/ directory. This is my attempt to portletize the (my new word) the web application.

A little needed info:

http://maven.apache.org/general.html#skip-test

Here's a little info on the technologies this application uses:

Sakai
Hibernate
JSF
MavenSpring

as if that wasn't enough. So I'm trying to wrap my head around this stuff here.

The goal of the day is to get the application to run as a portlet. So we'll see how far I get.

Sakai

Thursday, October 5. 2006


Building Sakai

_ _
| \/ |  _ _Apache_ _
| |\/| / ` \ V / -) ' \ ~ intelligent projects ~
|| |_,|_/__|||_| v. 1.0.2

Create build.properties in the %USERPROFILE% directory and place the following in the file:

maven.repo.remote = http://www.ibiblio.org/maven/,http://cvs.sakaiproject.org/maven/
maven.tomcat.home = d:/tomcat/

If the remote repository is not set to use http://cvs.sakaiproject.org/maven/ and http://www.ibiblio.org/maven the build will fail with an attempt to downloald the sakai-2.2.jar file, mail-1.3.1.jar, and other jar files. Once the build.properties is saved, before you can build sakai, you need to install the sakai plugin:

maven plugin:download -DgroupId=sakaiproject -DartifactId=sakai -Dversion=sakai.2.2

For more on using Maven to build Sakai, see the Using Maven page on the Sakai Wiki. I was almost overwhelmed by all the content on the Sakai Wiki. Cool stuff...


If you are using SQL Server, you must modify the hibernate mapping files, GradeMapping.hbm.xml and GradeScale.hbm.xml.

GradeMapping.hbm.xml modify line 25:
<element column="[PERCENT]" type="double"/>

GradeScale.hbm.xml modify line 32:
<element column="[PERCENT]" type="double"/>

Again, Percent is a keyword and the column names must be escaped.

Now from the sakai source root directory execute: maven sakai
This builds all the projects in the sakai source. If you only want to use the gradebook application, cd to the sections directory, modify the gradebook hibernate properties and execute:

maven -Dmode=standalone -Dhibernate.properties.dir=d:/projects/sakai-src/gradebook/app/standalone-app/src/hibernate cln bld

then execute:

# Regular standalone build and deploy to my test Tomcat server.
maven -Dstandalone=true cln bld

# Initialize my local database with the Gradebook tables.
# this creates a gradebook.sql in the standalone-app/target directory
# for ms sql server this gradebook.sql creates fields titled "PERCENT"
# this must be escaped with the brackets [PERCENT] since it is a keyword
maven schema-standalone

Here are is the sql statements I used to create the tables:

create table GB_GRADABLE_OBJECT_T (ID numeric(19,0) identity not null, OBJECT_TYPE_ID int not null, VERSION int not null, GRADEBOOK_ID numeric(19,0) not null, NAME varchar(255) not null, REMOVED tinyint null, POINTS_POSSIBLE double precision null, DUE_DATE datetime null, NOT_COUNTED tinyint null, EXTERNALLY_MAINTAINED tinyint null, EXTERNAL_STUDENT_LINK varchar(255) null, EXTERNAL_INSTRUCTOR_LINK varchar(255) null, EXTERNAL_ID varchar(255) null, EXTERNAL_APP_NAME varchar(255) null, primary key (ID));
create table GB_GRADEBOOK_T (ID numeric(19,0) identity not null, VERSION int not null, GRADEBOOK_UID varchar(255) not null unique, NAME varchar(255) not null, SELECTED_GRADE_MAPPING_ID numeric(19,0) null, ASSIGNMENTS_DISPLAYED tinyint not null, COURSE_GRADE_DISPLAYED tinyint not null, ALL_ASSIGNMENTS_ENTERED tinyint not null, LOCKED tinyint not null, primary key (ID));
create table GB_GRADE_MAP_T (ID numeric(19,0) identity not null, OBJECT_TYPE_ID int not null, VERSION int not null, GRADEBOOK_ID numeric(19,0) not null, GB_GRADING_SCALE_T numeric(19,0) null, primary key (ID));
create table GB_GRADE_RECORD_T (ID numeric(19,0) identity not null, OBJECT_TYPE_ID int not null, VERSION int not null, GRADABLE_OBJECT_ID numeric(19,0) not null, STUDENT_ID varchar(255) not null, GRADER_ID varchar(255) not null, DATE_RECORDED datetime not null, POINTS_EARNED double precision null, ENTERED_GRADE varchar(255) null, SORT_GRADE double precision null, primary key (ID), unique (GRADABLE_OBJECT_ID, STUDENT_ID));
create table GB_GRADE_TO_PERCENT_MAPPING_T (GRADE_MAP_ID numeric(19,0) not null, [PERCENT] double precision null, LETTER_GRADE varchar(255) not null, primary key (GRADE_MAP_ID, LETTER_GRADE));
create table GB_GRADING_EVENT_T (ID numeric(19,0) identity not null, GRADABLE_OBJECT_ID numeric(19,0) not null, GRADER_ID varchar(255) not null, STUDENT_ID varchar(255) not null, DATE_GRADED datetime not null, GRADE varchar(255) null, primary key (ID));
create table GB_GRADING_SCALE_GRADES_T (GRADING_SCALE_ID numeric(19,0) not null, LETTER_GRADE varchar(255) null, GRADE_IDX int not null, primary key (GRADING_SCALE_ID, GRADE_IDX));
create table GB_GRADING_SCALE_PERCENTS_T (GRADING_SCALE_ID numeric(19,0) not null, [PERCENT] double precision null, LETTER_GRADE varchar(255) not null, primary key (GRADING_SCALE_ID, LETTER_GRADE));
create table GB_GRADING_SCALE_T (ID numeric(19,0) identity not null, OBJECT_TYPE_ID int not null, VERSION int not null, SCALE_UID varchar(255) not null unique, NAME varchar(255) not null, UNAVAILABLE tinyint null, primary key (ID));
create table GB_PROPERTY_T (ID numeric(19,0) identity not null, VERSION int not null, NAME varchar(255) not null unique, VALUE varchar(255) null, primary key (ID));
alter table GB_GRADABLE_OBJECT_T add constraint FK759996A7325D7986 foreign key (GRADEBOOK_ID) references GB_GRADEBOOK_T;
alter table GB_GRADEBOOK_T add constraint FK7C870191552B7E63 foreign key (SELECTED_GRADE_MAPPING_ID) references GB_GRADE_MAP_T;
alter table GB_GRADE_MAP_T add constraint FKADE11225325D7986 foreign key (GRADEBOOK_ID) references GB_GRADEBOOK_T;
alter table GB_GRADE_MAP_T add constraint FKADE11225181E947A foreign key (GB_GRADING_SCALE_T) references GB_GRADING_SCALE_T;
create index GB_GRADE_RECORD_STUDENT_ID_IDX on GB_GRADE_RECORD_T (STUDENT_ID);
alter table GB_GRADE_RECORD_T add constraint FK46ACF7526F98CFF foreign key (GRADABLE_OBJECT_ID) references GB_GRADABLE_OBJECT_T;
alter table GB_GRADE_TO_PERCENT_MAPPING_T add constraint FKCDEA021162B659F1 foreign key (GRADE_MAP_ID) references GB_GRADE_MAP_T;
alter table GB_GRADING_EVENT_T add constraint FK4C9D99E06F98CFF foreign key (GRADABLE_OBJECT_ID) references GB_GRADABLE_OBJECT_T;
alter table GB_GRADING_SCALE_GRADES_T add constraint FK5D3F0C95605CD0C5 foreign key (GRADING_SCALE_ID) references GB_GRADING_SCALE_T;
alter table GB_GRADING_SCALE_PERCENTS_T add constraint FKC98BE467605CD0C5 foreign key (GRADING_SCALE_ID) references GB_GRADING_SCALE_T;
create index GB_GRADABLE_OBJ_ASN_IDX on GB_GRADABLE_OBJECT_T (OBJECT_TYPE_ID, GRADEBOOK_ID, NAME, REMOVED);
create index GB_GRADE_RECORD_O_T_IDX on GB_GRADE_RECORD_T (OBJECT_TYPE_ID);

If you want, you can load your local database with test data. If you do
this, you can skip the "schema-standalone" step above, since the data
load will automatically create all needed tables.

maven load-full-standalone

Blogging, IronPython, Linux

Wednesday, September 27. 2006

Wow... I can't believe a wait so long to post to this blog. Since I had issues with Blogger.com, I kind of got side tracked and wasn't too interested in my blog anymore. Not to mention the fact that I finished the Livestrong ride months ago and haven't been putting in hard hard efforts on the bicycle either.

So what's new with me. The usual work and play. I've still been riding about five days a week and have been looking for another event to participate in.

Linux Environment Variables - Quick Random Notes

Environment Variables on fedora 5 are set in the /etc/profile.d/ directory. Example "maven.sh":

export MAVEN_HOME=/usr/share/maven-1.0.2
export PATH=$MAVEN_HOME/bin:$PATH

Fedora 5 is using Common Internet File System instead of Samba. Thus to mount a share use the following:

mount -t cifs //server/share /mnt/mountdir -o username=domain\\username

As you can see I've been been trying to use Linux more and more...

IronPython

Now this language is rather interesting. It allows you to create and modify Windows Forms and Presentation Foundation applications on the fly. In order to get this working I had to download and install the Pre-Release Windows Vista .NET 3.0 Framework and Runtime and the Windows SDK for Windows Vista. In additon to the IronPython 1.0 release and the IronPython Samples.

Java and .NET playing nicely

Wednesday, September 20. 2006

Recently I needed and instance of uPortal to communicate with our Windows machines to have them do some work on behalf of the user that signed into uPortal. At first I tried to do this all in Java and quickly found out that this wasn't going to be very elegant, given that the Windows 2003 servers already have IIS and ASP .NET running on them. Thus I was faced with what I'm sure other have faced. I didn't want to start another web server just to respond to requests from the portal. Especially if it required starting another JVM. So, what to do, what to do. Well I just wrote a little .NET Web Service in C# (not difficult) to handle the requests and do the work. This was coming from never writing a web service in Visual Studio before.

Microsoft has done a good job at letting you create web services relatively straight forward in VS 2005.

C# Web ServiceTo create the web service in VS 2005, from the top menu create a new web site.


Create a New Web Site from the ASP .NET Web Service Template. From this dialog you can select the language of choice, C#, J#, or VB and the location of your files (Pretty self-explanatory).


VS create a bare bones, Hello World Web Service. At this point you have a web service that returns a simple string "Hello World" that we are all so familar with. You can build this solution and test it by setting a breakpoint and pressing "F5". While debugging on the local machine you're able to invoke methods from a web page which also provides a link to the service's WSDL. This makes it easy to create and debug the service before you have to write any code to consume the service.


If the HelloWorld method is invoked, the service returns a nice bit of xml code:

Hello World


In a few clicks, visual studio has created the application class file, Service.cs; the Web Service entry point, Service.asmx; and the web service configuration file, Web.config. For more information on the generated file, see the documentation on MSDN.

Now that the basic structure of the web service is in place. We can write code that actual does something instead of just respond with "Hello World".



Modify the Service

The whole .NET/Java relationship came into light because I needed to generate webs in IIS from a Java Application Server which resides on a different from the IIS server. So the Java App needed the ability to function as an administrator on the IIS.

In the Web Service application code, I first changed the Namespace to something meaningful, "http://www.iisserver.com/webgenerator".

WebService(Namespace = "http://www.iisserver.com/webgenerator/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService

Next I changed the HelloWorld method definition to:

public string generate(string account)

and add some database access to the body of the method. Basically the generate method looks in a database table for commands that need to be executed to create webs on the IIS server and executes those commands on the server. So here's the bulk of the method which is straight forward:



[WebMethod]
public string generate(string account) {

/**
conStr is the static connection string
/
SqlConnection conn = new SqlConnection(conStr); SqlConnection conn2 = new SqlConnection(conStr);
SqlDataReader accountReader = null;
SqlCommand sql;
/**
returns the exact path to the command shell executable. **/
string command = Environment.ExpandEnvironmentVariables("%comspec%");

string returnInfo = "";
string fpID = "0";

/ I've simplified this example so you don't have to look at all the code
/
try
{
sql = new SqlCommand("SELECT FrontPageID, Command "+
" FROM WebFrontPageRequest " +
"WHERE Account = '"+account+
"' AND Completed = 0",
conn);

conn.Open();
accountReader = sql.ExecuteReader();
do
{
while(accountReader.Read())
{
fpID = accountReader["FrontPageID"].ToString();
conn2.Open();

/** Update the command **/
sql = new SqlCommand("UPDATE "+
"WebFrontPageRequest SET "+
"Completed = 1 WHERE FrontPageID = "+

fpID, conn2);
sql.ExecuteNonQuery();
conn2.Close();
string readerCmd = accountReader["Command"].ToString();
ProcessStartInfo startInfo = new ProcessStartInfo(command,args);
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
startInfo.WindowStyle = ProcessWindowStyle.Normal;
startInfo.CreateNoWindow = false;
Process proc = Process.Start(startInfo);
proc.WaitForExit();

if (proc.ExitCode != 0)
{
// TODO: clean up your mess
returnInfo = returnInfo+
"unsuccessful "+
command+args+
proc.StandardOutput.ReadToEnd()
+"\n" +

proc.StandardError.ReadToEnd()
+"\n";

}
else
{
returnInfo = returnInfo+
"successful "+
proc.StandardOutput.ReadToEnd();

}
}
} while(accountReader.NextResult());

}
catch(Exception e)
{
conn2.Open();
sql = new SqlCommand("UPDATE WebFrontPageRequest "+
"SET
Completed = 0 "+
"WHERE FrontPageID = "+
fpID, conn2);

sql.ExecuteNonQuery();
conn2.Close();
return e.Message;
}
finally
{
if(accountReader != null)
accountReader.Close();
conn.Close();
conn2.Close();
}
return returnInfo;
}
(For more on C# and database access, see Accessing Data with ADO.NET or http://www.c-sharpcorner.com/Database.asp)
Now that there is a method to do some work, the web service can be built and published to a production server. There is an option to publish the service under the build menu.

Once the service is on production server is when the real fun begins which brings us to the Application Pool but before I get to the Application pool here's a little brief on the new issue. Up to this point, there is a web service that is attempting to create webs on an IIS server. Well when the service is called I can see the service start and then die. IIS runs under the ASPNET account which doesn't have administrative rights to execute commands like owadmin.exe, or cacls.exe, etc. Since the server is providing services for multiple users I didn't want to grant ASPNET the rights to satisfy the requests of the service because others could then write code that utilizes these rights. Thus, I had to create a new local account and grant it administrative rights. If you use my approach, you will also have to grant the account rights to log on as a service. For more information on "IIS 6 & Service Unavailable Errors" see Brian Desmond's Blog. You'll have to modify the security settings for your new account before the Web Service will execute without error. You need to make sure that the new account has setting to log on as a service. You can get a good idea of what is needed by looking at the ASPNET account security settings.

Application Pool

Application Pools allow .NET applications to run in isolation of each other. Each pool has it's own worker process, thus, if one pool chokes, it won't affect the other applications running on the system. For my purposes, I have multiple application running on the server, most of which are out of my control and don't need special priviledges to do their work. However, the web service that was created does need rights. So, I configured a new application pool to run as another user for the web service and only the web service.

To create a new Application Pool, from the IIS manager, there is a folder called "Application Pools", right click on the folder and select "New" -> "Application Pool".

From the next dialog, name your Application Pool. I also selected to use the default app pool as a template. This allowed me to take advantage of configurations that already exist in the default pool.

Once the new app pool is created, you need to modify the pool's identity. Initially the pool uses the Network Service account. I changed this to use the new user administrative account created above. This will allow the worker process to execute the commands needed to generate a web.

For more on application pools, see the article on http://www.developer.com/net/asp/article.php/2245511. Now that the application pool is configured, the web site that hosts the application must be configured to use the new pool. To configure the pool, go to "Web Sites" in IIS and right click on the web that is hosting the web service. Select "Properties". From the properties dialog you can set the application pool that this web will use from the lower drop-down list.

Once the pool is set, restart the web. Now the web service is running under an account that has proper rights to execute the tools needed to create webs on the server.

On a side note, I've seen posts where users are trying to impersonate an administrative account to execute tools like owsadm.exe. This will not work because the web application is running under the ASPNET account and doesn't have proper rights to execute those tools. Often I see users using the ProcessStartInfo object to impersonate the administrator like:

ProcessStartInfo.Username
ProcessStartInfo.Password
ProcessStartInfoDomain

This doesn't work and the process will hang or if you set a timeout, it will be killed without ever doing the work because the CreateProcess API is called, and the Platform SDK states: "If the calling process is impersonating another user, the new process uses the token for the calling process, not the impersonation token". Since the underlining process is ASPNET, the process doesn't work. My work around, was to create a new pool running under a less restrictive process solely to execute tools and whalla!

Apache Axis

Back to Java! The Apache Group has come out with some really helpful tools to get me through my day; Ant, Commons, Maven2, Tomcat, to name a few. For consuming web services, I don't think they could make it much easier with Axis. The when you download Axis it comes with a tool to convert a WSDL to client bindings, WSDL2Java, which allows you to consume a web service in a few lines of code, but before we look at the client code, here's how I generated the bindings:

java org.apache.axis.wsdl.WSDL2Java http://mywebservice.url/Service.asmx?WSDL

Executing the WSDL2Java tool created, five Java classes:

Service.java
ServiceLocator.java
ServiceSoap.java
ServiceSoap12.java
ServiceSoapStub.java

The generated classes are described in the table below (from the Axis site)

WSDL clauseJava class(es) generated
For each entry in the type sectionA java class
A holder if this type is used as an inout/out parameter
For each portTypeA java interface
For each bindingA stub class
For each serviceA service interface
A service implementation (the locator)


Once the Axis classes have been compiled I can use them to invoke the web service as follows:

import edu.fullcoll.axis.stubs.*;

public class TestClient {
public static void main(String [] args) {
try {
ServiceLocator loc = new ServiceLocator();
ServiceSoap port = loc.getServiceSoap();
System.out.println(port.generate("webaccount");
} catch (Exception e) {
System.err.println(e.toString());
}
}
}

This main should output something like "successful", if all goes well. At which point I am satisfied that I can incorporate this snippet of code into a portlet or any other Java application to access a .NET service.

The coding of the application wasn't difficult, just getting all the pieces to function properly since I wasn't that familiar with .NET and impersonation or .NET application pools. Additions to the code, I added some security to the web service to ensure that only authorized users have access to the service. You can get information on securing your ASP application at
MSDN. Hopefully this helps if you're trying to get these two worlds to function in harmony. With the help of Apache and Microsoft, this whole process was a lot easier than I had planned. Enjoy!