You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by di...@apache.org on 2004/08/09 18:35:37 UTC
cvs commit: ws-fx/addressing/src/org/apache/ws/addressing/uuid JugUUIdGenerator.java UUIdGenerator.java UUIdGeneratorFactory.java
dims 2004/08/09 09:35:37
Added: addressing/src/org/apache/ws/addressing/uuid
JugUUIdGenerator.java UUIdGenerator.java
UUIdGeneratorFactory.java
Log:
Contribution from Ian Springer <ia...@hp.com>
===================================================
The attached classes are intended to replace the existing class
AddressingHandler. They are in the following class hierarchies, which
are designed to facilitate easy porting to any JAX-RPC container:
AxisClientSideAddressingHandler extends ClientSideAddressingHandler
extends AbstractAddressingHandler
AxisServerSideAddressingHandler extends ServerSideAddressingHandler
extends AbstractAddressingHandler
AbstractAddressingHandler is an abstract base class containing
functionality shared by server-side and client-side handlers.
ClientSideAddressingHandler and ServerSideAddressingHandler are
client-side and server-side JAX-RPC handlers, respectively, that should
work within any JAX-RPC container. They contain a few methods that can
be overridden by platform-specific subclasses to provide more robust
functionality. AxisClientSideAddressingHandler and
AxisServerSideAddressingHandler are subclasses of the platform-neutral
handlers that implement the Axis Handler interface and that leverage
some Axis-specific APIs in overridden methods.
All platform-neutral classes are below the org.apache.ws.addressing
package, and all Axis-specific classes are below
org.apache.axis.message.addressing.handler.
I've written unit tests that test the key methods - handleRequest() and
handleResponse() - in the platform-neutral handlers.
Additionally, I've written an interface and factory that allow one to
easily plug in different UUID-generation impls. The platform-neutral
handlers utilize the opensource JUG library as the UUID generator, but
use refelction to avoid a compile-time dependency on it. The
Axis-specific handlers utilize the UUID generator that comes with Axis.
There are still a number of data structure classes and interfaces in
Apache Addressing that use Axis-specific classes like MessageElement and
URI. These could be refactored fairly easily to be platform-neutral.
Once this is done, Apache Addressing will be a portable WS-Addressing
implementation that can be deployed and utilized on any JAX-RPC
container. I think this will broaden the project's user and developer
base.
===================================================
Revision Changes Path
1.1 ws-fx/addressing/src/org/apache/ws/addressing/uuid/JugUUIdGenerator.java
Index: JugUUIdGenerator.java
===================================================================
/*
* Copyright 2004 The Apache Software Foundation.
*
* Licensed 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.ws.addressing.uuid;
import javax.xml.rpc.JAXRPCException;
import java.lang.reflect.Method;
/**
* A {@link UUIdGenerator} implementation that uses JUG, an opensource Java UUID generation
* library. Reflection is utilized to avoid a compile-time dependency on jug.jar.
*
* @author Ian P. Springer <ia...@hp.com>
*/
public class JugUUIdGenerator implements UUIdGenerator {
private static final String JUG_UUIDGENERATOR_CLASSNAME = "org.doomdark.uuid.UUIDGenerator";
private static final String JUG_WEBSITE_URL = "http://www.doomdark.org/doomdark/proj/jug/";
private static Method generateUUIdMethod;
private static Method newInstanceMethod;
static {
Class jugUuidGenClass = null;
try {
jugUuidGenClass = Class.forName(JUG_UUIDGENERATOR_CLASSNAME);
} catch (ClassNotFoundException cnfe) {
throw new RuntimeException("Java UUID Generator (JUG) " + JUG_UUIDGENERATOR_CLASSNAME + " not found. Please add jug.jar, from " + JUG_WEBSITE_URL + ", to your classpath and restart.");
}
try {
newInstanceMethod = jugUuidGenClass.getMethod("getInstance", new Class[0]);
generateUUIdMethod = jugUuidGenClass.getMethod("generateTimeBasedUUID", new Class[0]);
} catch (Exception e) {
throw new RuntimeException("Fatal error initializing Java UUID Generator (JUG) " + JUG_UUIDGENERATOR_CLASSNAME + ".");
}
}
private ThreadLocal JUG_UUIDGENERATOR =
new ThreadLocal() {
protected synchronized Object initialValue() {
try {
return newInstanceMethod.invoke(null, new Object[0]);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
};
public String generateUUId() {
try {
return generateUUIdMethod.invoke(JUG_UUIDGENERATOR.get(), new Object[0]).toString();
} catch (Exception e) {
throw new JAXRPCException(e);
}
}
}
1.1 ws-fx/addressing/src/org/apache/ws/addressing/uuid/UUIdGenerator.java
Index: UUIdGenerator.java
===================================================================
/*
* Copyright 2004 The Apache Software Foundation.
*
* Licensed 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.ws.addressing.uuid;
/**
* Provides the ability to generate Universally Unique IDentifiers (UUIDs).
* Use {@link UUIdGeneratorFactory#createUUIdGenerator()} or
* {@link UUIdGeneratorFactory#createUUIdGenerator(String)} to obtain
* {@link UUIdGenerator} instances.
*
* @author Ian P. Springer <ia...@hp.com>
*/
public interface UUIdGenerator {
/**
* Generate a Universally Unique IDentifier (UUID).
*
* @return a Universally Unique IDentifier (UUID)
*/
String generateUUId();
}
1.1 ws-fx/addressing/src/org/apache/ws/addressing/uuid/UUIdGeneratorFactory.java
Index: UUIdGeneratorFactory.java
===================================================================
/*
* Copyright 2004 The Apache Software Foundation.
*
* Licensed 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.ws.addressing.uuid;
/**
* A {@link UUIdGenerator} factory.
*
* @author Ian P. Springer <ia...@hp.com>
*/
public class UUIdGeneratorFactory {
/**
* NOTE: Use string instead of Class to avoid dependency on jug.jar.
*/
private static final String IMPL_CLASSNAME_JUG = "org.apache.ws.addressing.uuid.JugUUIdGenerator";
public static final String DEFAULT_IMPL_CLASSNAME = IMPL_CLASSNAME_JUG;
public static UUIdGenerator createUUIdGenerator() throws RuntimeException {
return createUUIdGenerator(DEFAULT_IMPL_CLASSNAME);
}
public static UUIdGenerator createUUIdGenerator(Class implClass) throws RuntimeException {
try {
return (UUIdGenerator) implClass.newInstance();
} catch (Exception e) {
throw new RuntimeException("Failed to instantiate UUID generator " + implClass.getName() + ".", e);
}
}
public static UUIdGenerator createUUIdGenerator(String implClassname) throws RuntimeException {
try {
return createUUIdGenerator(Class.forName(implClassname));
} catch (Exception e) {
throw new RuntimeException("Failed to instantiate UUID generator " + implClassname + ".", e);
}
}
}