You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsrf-commits@ws.apache.org by ip...@apache.org on 2005/07/16 03:23:24 UTC
svn commit: r219275 [2/3] - in /webservices/wsrf/trunk: ./ jndi-config/
jndi-config/src/schema/
src/examples/filesystem/src/java/org/apache/ws/resource/example/filesystem/
src/examples/interop/src/java/org/oasisOpen/docs/wsrf/x2005/x01/wsrfInterop20Dra...
Modified: webservices/wsrf/trunk/src/java/org/apache/ws/resource/impl/ResourceSweeper.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/resource/impl/ResourceSweeper.java?rev=219275&r1=219274&r2=219275&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/resource/impl/ResourceSweeper.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/resource/impl/ResourceSweeper.java Fri Jul 15 18:23:20 2005
@@ -22,7 +22,6 @@
import org.apache.ws.resource.Resource;
import org.apache.ws.resource.ResourceException;
import org.apache.ws.resource.ResourceHome;
-import org.apache.ws.resource.ResourceKey;
import org.apache.ws.resource.i18n.Keys;
import org.apache.ws.resource.i18n.MessagesImpl;
import org.apache.ws.resource.lifetime.ScheduledResourceTerminationResource;
@@ -108,16 +107,16 @@
LOG.debug( MSG.getMessage( Keys.CLEANING_EXPIRED_RESOURCES) );
Calendar currentTime = Calendar.getInstance( );
- ResourceKey key;
+ Object key;
Resource resource;
LinkedList list = new LinkedList( );
synchronized ( m_resources )
{
- Iterator keyIterator = m_resources.keySet( ).iterator( );
- while ( keyIterator.hasNext( ) )
+ Iterator keyIter = m_resources.keySet( ).iterator( );
+ while ( keyIter.hasNext( ) )
{
- key = (ResourceKey) keyIterator.next( );
+ key = keyIter.next( );
try
{
resource = getResource( key );
@@ -133,10 +132,10 @@
}
}
- Iterator iter = list.iterator( );
- while ( iter.hasNext( ) )
+ Iterator expiredKeyIter = list.iterator( );
+ while ( expiredKeyIter.hasNext( ) )
{
- key = (ResourceKey) iter.next( );
+ key = expiredKeyIter.next( );
try
{
m_home.remove( key );
@@ -170,15 +169,15 @@
/**
* DOCUMENT_ME
*
- * @param key DOCUMENT_ME
+ * @param id DOCUMENT_ME
*
* @return DOCUMENT_ME
*
* @throws ResourceException DOCUMENT_ME
*/
- protected Resource getResource( ResourceKey key )
+ protected Resource getResource( Object id )
throws ResourceException
{
- return m_home.find( key );
+ return m_home.find( id );
}
}
Modified: webservices/wsrf/trunk/src/java/org/apache/ws/resource/lifetime/v2004_06/porttype/impl/ImmediateResourceTerminationPortTypeImpl.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/resource/lifetime/v2004_06/porttype/impl/ImmediateResourceTerminationPortTypeImpl.java?rev=219275&r1=219274&r2=219275&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/resource/lifetime/v2004_06/porttype/impl/ImmediateResourceTerminationPortTypeImpl.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/resource/lifetime/v2004_06/porttype/impl/ImmediateResourceTerminationPortTypeImpl.java Fri Jul 15 18:23:20 2005
@@ -66,15 +66,15 @@
public DestroyResponseDocument destroy( DestroyDocument requestDoc )
{
LOG.debug( MSG.getMessage( Keys.DESTROYING_RESOURCE, getResourceContext().getServiceName(),
- String.valueOf( getResourceKey() ) ) );
+ String.valueOf( getResource().getID() ) ) );
try
{
- getResourceHome().remove( getResourceKey() );
+ getResourceContext().getResourceHome().remove( getResource().getID() );
}
catch ( ResourceException re )
{
throw new ResourceNotDestroyedFaultException( NAMESPACE_SET, String.valueOf(
- getResourceKey().getValue() ),
+ String.valueOf( getResource().getID() ) ),
getResourceContext().getServiceName() );
}
Modified: webservices/wsrf/trunk/src/java/org/apache/ws/resource/lifetime/v2004_06/porttype/impl/ScheduledResourceTerminationPortTypeImpl.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/resource/lifetime/v2004_06/porttype/impl/ScheduledResourceTerminationPortTypeImpl.java?rev=219275&r1=219274&r2=219275&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/resource/lifetime/v2004_06/porttype/impl/ScheduledResourceTerminationPortTypeImpl.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/resource/lifetime/v2004_06/porttype/impl/ScheduledResourceTerminationPortTypeImpl.java Fri Jul 15 18:23:20 2005
@@ -79,7 +79,14 @@
// if requested termination time is in the past, destroy immediately
if ( ( requestedTermTime != null ) && requestedTermTime.getTime().before( currentTime.getTime() ) )
{
- destroyResource();
+ try
+ {
+ destroyResource();
+ }
+ catch ( ResourceException re )
+ {
+ throw new UnableToSetTerminationTimeFaultException( NAMESPACE_SET, null );
+ }
newTermTime = currentTime;
}
else
@@ -114,18 +121,11 @@
return responseDoc;
}
- private void destroyResource()
+ private void destroyResource() throws ResourceException
{
LOG.debug( MSG.getMessage( Keys.DESTROYING_RESOURCE, getResourceContext().getServiceName(),
- String.valueOf( getResourceKey() ) ) );
- try
- {
- getResourceHome().remove( getResourceKey() );
- }
- catch ( ResourceException re )
- {
- throw new UnableToSetTerminationTimeFaultException( NAMESPACE_SET, null );
- }
+ String.valueOf( getResource().getID() ) ) );
+ getResourceContext().getResourceHome().remove( getResource().getID() );
}
private void populateResponseDocument( SetTerminationTimeResponseDocument responseDoc,
Modified: webservices/wsrf/trunk/src/java/org/apache/ws/resource/lifetime/v2004_11/porttype/impl/ImmediateResourceTerminationPortTypeImpl.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/resource/lifetime/v2004_11/porttype/impl/ImmediateResourceTerminationPortTypeImpl.java?rev=219275&r1=219274&r2=219275&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/resource/lifetime/v2004_11/porttype/impl/ImmediateResourceTerminationPortTypeImpl.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/resource/lifetime/v2004_11/porttype/impl/ImmediateResourceTerminationPortTypeImpl.java Fri Jul 15 18:23:20 2005
@@ -73,14 +73,14 @@
public DestroyResponseDocument destroy( DestroyDocument requestDoc )
{
LOG.debug( MSG.getMessage( Keys.DESTROYING_RESOURCE ,getResourceContext( ).getServiceName( ) ,
- String.valueOf(getResourceKey( ))) );
+ String.valueOf(getResource().getID())) );
try
{
- getResourceHome( ).remove( getResourceKey( ) );
+ getResourceContext().getResourceHome( ).remove( getResource().getID() );
}
catch ( ResourceException re )
{
- throw new ResourceNotDestroyedFaultException(NAMESPACE_SET, String.valueOf( getResourceKey( ).getValue( ) ),
+ throw new ResourceNotDestroyedFaultException(NAMESPACE_SET, String.valueOf( getResource().getID() ),
getResourceContext( ).getServiceName( ) );
}
Modified: webservices/wsrf/trunk/src/java/org/apache/ws/resource/lifetime/v2004_11/porttype/impl/ScheduledResourceTerminationPortTypeImpl.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/resource/lifetime/v2004_11/porttype/impl/ScheduledResourceTerminationPortTypeImpl.java?rev=219275&r1=219274&r2=219275&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/resource/lifetime/v2004_11/porttype/impl/ScheduledResourceTerminationPortTypeImpl.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/resource/lifetime/v2004_11/porttype/impl/ScheduledResourceTerminationPortTypeImpl.java Fri Jul 15 18:23:20 2005
@@ -27,7 +27,6 @@
import org.apache.ws.resource.properties.NamespaceVersionHolder;
import org.apache.ws.resource.properties.impl.AbstractResourcePropertiesPortType;
import org.apache.ws.resource.properties.v2004_11.impl.NamespaceVersionHolderImpl;
-import org.apache.ws.resource.properties.v2004_11.impl.NamespaceVersionHolderImpl;
import org.apache.ws.util.i18n.Messages;
import org.oasisOpen.docs.wsrf.x2004.x11.wsrfWSResourceLifetime12Draft04.SetTerminationTimeDocument;
import org.oasisOpen.docs.wsrf.x2004.x11.wsrfWSResourceLifetime12Draft04.SetTerminationTimeResponseDocument;
@@ -35,32 +34,31 @@
import java.util.Calendar;
/**
- * LOG-DONE
- * An implementation of the wsrlw:ScheduledResourceTermination portType.
+ * LOG-DONE An implementation of the wsrlw:ScheduledResourceTermination portType.
*
* @author Ian P. Springer (Hewlett-Packard Company)
*/
public class ScheduledResourceTerminationPortTypeImpl
- extends AbstractResourcePropertiesPortType
- implements ScheduledResourceTerminationPortType
+ extends AbstractResourcePropertiesPortType
+ implements ScheduledResourceTerminationPortType
{
- /**
- * DOCUMENT_ME
- */
- private static final Log LOG = LogFactory.getLog( ScheduledResourceTerminationPortTypeImpl.class.getName( ) );
-
- private static final Messages MSG = MessagesImpl.getInstance();
- private static final NamespaceVersionHolder NAMESPACE_SET = new NamespaceVersionHolderImpl() ;
-
- /**
- * Creates a new {@link ScheduledResourceTerminationPortTypeImpl} object.
- *
- * @param resourceContext DOCUMENT_ME
- */
- public ScheduledResourceTerminationPortTypeImpl( ResourceContext resourceContext )
- {
- super( resourceContext );
- }
+ /**
+ * DOCUMENT_ME
+ */
+ private static final Log LOG = LogFactory.getLog( ScheduledResourceTerminationPortTypeImpl.class.getName() );
+
+ private static final Messages MSG = MessagesImpl.getInstance();
+ private static final NamespaceVersionHolder NAMESPACE_SET = new NamespaceVersionHolderImpl();
+
+ /**
+ * Creates a new {@link ScheduledResourceTerminationPortTypeImpl} object.
+ *
+ * @param resourceContext DOCUMENT_ME
+ */
+ public ScheduledResourceTerminationPortTypeImpl( ResourceContext resourceContext )
+ {
+ super( resourceContext );
+ }
protected NamespaceVersionHolder getNamespaceSet()
{
@@ -68,74 +66,74 @@
}
/**
- * DOCUMENT_ME
- *
- * @param requestDoc DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- public SetTerminationTimeResponseDocument setTerminationTime( SetTerminationTimeDocument requestDoc )
- {
- SetTerminationTimeResponseDocument responseDoc = createResponseDocument( );
- Calendar currentTime = Calendar.getInstance( );
- Calendar requestedTermTime =
- requestDoc.getSetTerminationTime( ).getRequestedTerminationTime( );
- Calendar newTermTime = null;
-
- // if requested termination time is in the past, destroy immediately
- if ( ( requestedTermTime != null ) && requestedTermTime.getTime( ).before( currentTime.getTime( ) ) )
- {
- destroyResource( );
- newTermTime = currentTime;
- }
- else
- {
- newTermTime = requestedTermTime;
- }
-
- getResourceState( ).setTerminationTime( newTermTime );
- populateResponseDocument( responseDoc, currentTime, newTermTime );
- return responseDoc;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- protected final ScheduledResourceTerminationResource getResourceState( )
- {
- return (ScheduledResourceTerminationResource) getResource( );
- }
-
- private SetTerminationTimeResponseDocument createResponseDocument( )
- {
- SetTerminationTimeResponseDocument responseDoc = SetTerminationTimeResponseDocument.Factory.newInstance( );
- responseDoc.addNewSetTerminationTimeResponse( );
- return responseDoc;
- }
-
- private void destroyResource( )
- {
- LOG.debug( MSG.getMessage( Keys.DESTROYING_RESOURCE,getResourceContext( ).getServiceName( ),
- String.valueOf( getResourceKey( ))) );
- try
- {
- getResourceHome( ).remove( getResourceKey( ) );
- }
- catch ( ResourceException re )
- {
- throw new UnableToSetTerminationTimeFaultException(NAMESPACE_SET, null );
- }
- }
-
- private void populateResponseDocument( SetTerminationTimeResponseDocument responseDoc,
- Calendar currentTime,
- Calendar newTermTime )
- {
- SetTerminationTimeResponseDocument.SetTerminationTimeResponse response =
- responseDoc.getSetTerminationTimeResponse( );
- response.setCurrentTime( currentTime );
- response.setNewTerminationTime( newTermTime );
- }
+ * DOCUMENT_ME
+ *
+ * @param requestDoc DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public SetTerminationTimeResponseDocument setTerminationTime( SetTerminationTimeDocument requestDoc )
+ {
+ SetTerminationTimeResponseDocument responseDoc = createResponseDocument();
+ Calendar currentTime = Calendar.getInstance();
+ Calendar requestedTermTime =
+ requestDoc.getSetTerminationTime().getRequestedTerminationTime();
+ Calendar newTermTime = null;
+
+ // if requested termination time is in the past, destroy immediately
+ if ( ( requestedTermTime != null ) && requestedTermTime.getTime().before( currentTime.getTime() ) )
+ {
+ try
+ {
+ destroyResource();
+ }
+ catch ( ResourceException re )
+ {
+ throw new UnableToSetTerminationTimeFaultException( NAMESPACE_SET, null );
+ }
+ newTermTime = currentTime;
+ }
+ else
+ {
+ newTermTime = requestedTermTime;
+ }
+
+ getResourceState().setTerminationTime( newTermTime );
+ populateResponseDocument( responseDoc, currentTime, newTermTime );
+ return responseDoc;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ protected final ScheduledResourceTerminationResource getResourceState()
+ {
+ return (ScheduledResourceTerminationResource) getResource();
+ }
+
+ private SetTerminationTimeResponseDocument createResponseDocument()
+ {
+ SetTerminationTimeResponseDocument responseDoc = SetTerminationTimeResponseDocument.Factory.newInstance();
+ responseDoc.addNewSetTerminationTimeResponse();
+ return responseDoc;
+ }
+
+ private void destroyResource() throws ResourceException
+ {
+ LOG.debug( MSG.getMessage( Keys.DESTROYING_RESOURCE, getResourceContext().getServiceName(),
+ String.valueOf( getResource().getID() ) ) );
+ getResourceContext().getResourceHome().remove( getResource().getID() );
+ }
+
+ private void populateResponseDocument( SetTerminationTimeResponseDocument responseDoc,
+ Calendar currentTime,
+ Calendar newTermTime )
+ {
+ SetTerminationTimeResponseDocument.SetTerminationTimeResponse response =
+ responseDoc.getSetTerminationTimeResponse();
+ response.setCurrentTime( currentTime );
+ response.setNewTerminationTime( newTermTime );
+ }
}
Added: webservices/wsrf/trunk/src/java/org/apache/ws/resource/webapp/WsrfServer.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/resource/webapp/WsrfServer.java?rev=219275&view=auto
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/resource/webapp/WsrfServer.java (added)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/resource/webapp/WsrfServer.java Fri Jul 15 18:23:20 2005
@@ -0,0 +1,164 @@
+/*=============================================================================*
+ * Copyright 2005 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.resource.webapp;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.PosixParser;
+import org.mortbay.http.SocketListener;
+import org.mortbay.jetty.Server;
+import org.mortbay.util.MultiException;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * A standalone WSRF server that uses Jetty as the HTTP server and servlet container
+ * and uses Axis as the SOAP engine.
+ *
+ * @author Ian Springer
+ */
+public class WsrfServer
+{
+
+ protected static final org.apache.commons.cli.Options CMD_LINE_OPTIONS = new org.apache.commons.cli.Options();
+
+ static
+ {
+ initCmdLineOptions();
+ }
+
+ /**
+ * Jetty HTTP server / servlet container
+ */
+ private Server m_server;
+
+ private SocketListener m_listener = new SocketListener();
+
+ private File m_webappPath;
+
+ /**
+ * Creates a WsrfServer for running the specified web application.
+ *
+ * @param webappPath the path to an Apache-WSRF-based webapp (directory or warfile)
+ *
+ * @throws IOException if the webapp path is invalid
+ */
+ public WsrfServer( File webappPath ) throws IOException
+ {
+ m_webappPath = webappPath;
+ m_server = new Server();
+ m_server.addListener(m_listener);
+ String contextName = m_webappPath.getName();
+ m_server.addWebApplication( "/" + contextName + "/*", m_webappPath.getAbsolutePath() );
+ }
+
+ /**
+ * Sets the HTTP listen port.
+ *
+ * @param port the port number
+ */
+ public void setPort(int port) {
+ m_listener.setPort(port);
+ }
+
+ /**
+ * Gets the HTTP listen port.
+ */
+ public int getPort() {
+ return m_listener.getPort();
+ }
+
+ /**
+ * Gets the webapp path.
+ */
+ public File getWebappPath()
+ {
+ return m_webappPath;
+ }
+
+ /**
+ * Starts the server.
+ *
+ * @throws MultiException
+ */
+ public void start() throws MultiException {
+ m_server.start();
+ }
+
+ /**
+ * Stops the server.
+ *
+ * @throws InterruptedException
+ */
+ public void stop() throws InterruptedException {
+ m_server.stop();
+ }
+
+ private static void initCmdLineOptions()
+ {
+ CMD_LINE_OPTIONS.addOption(Opts.PORT,
+ LongOpts.PORT,
+ true,
+ "server listen port");
+ }
+
+ /**
+ * DOCUMENT_ME
+ */
+ static interface LongOpts
+ {
+ /**
+ * DOCUMENT_ME
+ */
+ String PORT = "port";
+ }
+
+ /**
+ * DOCUMENT_ME
+ */
+ static interface Opts
+ {
+ /**
+ * DOCUMENT_ME
+ */
+ String PORT = "p";
+ }
+
+ /**
+ * A main method for starting a server instance.
+ * Usage: org.apache.ws.resource.webapp.WsrfServer [-p port] webappPath
+ *
+ * @param args command-line arguments
+ *
+ * @throws Exception on any error
+ */
+ public static void main(String[] args) throws Exception
+ {
+ CommandLine cmdLine = new PosixParser().parse(CMD_LINE_OPTIONS, args, true);
+ if ( cmdLine.getArgs().length != 1 )
+ {
+ throw new IllegalArgumentException( "Usage: " + WsrfServer.class.getName() + " [-p port] webappPath");
+ }
+ File webappPath = new File( cmdLine.getArgs()[0] );
+ WsrfServer server = new WsrfServer( webappPath );
+ if (cmdLine.hasOption(Opts.PORT))
+ {
+ server.setPort( Integer.valueOf( cmdLine.getOptionValue( Opts.PORT ) ).intValue() );
+ }
+ server.start();
+ }
+
+}
Modified: webservices/wsrf/trunk/src/java/org/apache/ws/resource/webapp/WsrfServletContextListener.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/resource/webapp/WsrfServletContextListener.java?rev=219275&r1=219274&r2=219275&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/resource/webapp/WsrfServletContextListener.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/resource/webapp/WsrfServletContextListener.java Fri Jul 15 18:23:20 2005
@@ -52,7 +52,7 @@
{
InputStream jndiConfigStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(
XmlBeanJndiUtils.JNDI_CONFIG_FILENAME );
- XmlBeanJndiUtils.initializeFromInputStream( jndiConfigStream );
+ XmlBeanJndiUtils.initFromInputStream( jndiConfigStream );
}
catch ( Exception e )
{
Modified: webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/DefaultParameters.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/DefaultParameters.java?rev=219275&r1=219274&r2=219275&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/DefaultParameters.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/DefaultParameters.java Fri Jul 15 18:23:20 2005
@@ -1,10 +1,7 @@
package org.apache.ws.util.jndi;
-
-
-
-/** LOG-DONE
- * A bean to hold default values for Service parameters in the JNDI config file.
+/**
+ * A bean to hold default values for Service config parameters.
*
* @author Sal Campana
*/
@@ -12,8 +9,6 @@
{
private String m_defaultFactory = org.apache.ws.util.jndi.BeanFactory.class.getName();
- private String m_defaultResourceKeyClassName = org.apache.ws.resource.impl.SimpleTypeResourceKey.class.getName();
-
public String getFactory()
{
return m_defaultFactory;
@@ -24,13 +19,4 @@
m_defaultFactory = defaultFactory;
}
- public String getResourceKeyClassName()
- {
- return m_defaultResourceKeyClassName;
- }
-
- public void setResourceKeyClassName(String resourceKeyClassName)
- {
- m_defaultResourceKeyClassName = resourceKeyClassName;
- }
}
Modified: webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/JNDIUtils.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/JNDIUtils.java?rev=219275&r1=219274&r2=219275&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/JNDIUtils.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/JNDIUtils.java Fri Jul 15 18:23:20 2005
@@ -1,4 +1,3 @@
-
package org.apache.ws.util.jndi;
import org.apache.axis.AxisEngine;
@@ -8,7 +7,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.naming.ContextBindings;
-import org.apache.ws.resource.handler.axis.ContainerConfig;
import org.apache.ws.util.DeployConstants;
import org.apache.ws.util.jndi.tools.JNDIConfigRuleSet;
@@ -26,41 +24,40 @@
import java.io.InputStream;
import java.util.StringTokenizer;
-/** LOG-DONE
- * A utility class containing methods for setting up the JNDI environment and
- * performing JNDI lookups
+/**
+ * LOG-DONE A utility class containing methods for setting up the JNDI environment and performing JNDI lookups
*/
public class JNDIUtils
{
//TODO: most of these methods should be internal only
private static Log LOG =
- LogFactory.getLog(JNDIUtils.class.getName());
- /**
- * Apache JNDI URL Package Prefix
- */
- public static final String APACHE_URL_PKG_PREFIX = "org.apache.naming";
-
- /**
- * Apache JNDI Initial Context Factory Prefix
- */
- public static final String APACHE_INITIAL_CONTEXT_FACTORY =
- "org.apache.naming.java.javaURLContextFactory";
+ LogFactory.getLog( JNDIUtils.class.getName() );
+ /**
+ * Apache JNDI URL Package Prefix
+ */
+ public static final String APACHE_URL_PKG_PREFIX = "org.apache.naming";
+
+ /**
+ * Apache JNDI Initial Context Factory Prefix
+ */
+ public static final String APACHE_INITIAL_CONTEXT_FACTORY =
+ "org.apache.naming.java.javaURLContextFactory";
public static final String JNDI_CONFIG = "jndi-config.xml";
private static Context initialContext = null;
/**
- * Configure JNDI with the Apache Tomcat naming service classes and create
- * the comp and env contexts
+ * Configure JNDI with the Apache Tomcat naming service classes and create the comp and env contexts
*
* @return The initial context
+ *
* @throws Exception
*/
public static Context initJNDI()
- throws Exception
+ throws Exception
{
- LOG.debug("Initializing JNDI.");
+ LOG.debug( "Initializing JNDI." );
Context result = null;
Context compContext = null;
@@ -68,11 +65,11 @@
String value = APACHE_URL_PKG_PREFIX;
String oldValue =
- System.getProperty(Context.URL_PKG_PREFIXES);
+ System.getProperty( Context.URL_PKG_PREFIXES );
- if(oldValue != null)
+ if ( oldValue != null )
{
- if(oldValue.startsWith(value + ":"))
+ if ( oldValue.startsWith( value + ":" ) )
{
value = oldValue;
}
@@ -81,221 +78,187 @@
value = value + ":" + oldValue;
}
}
- LOG.debug("Setting System Property " + Context.URL_PKG_PREFIXES + " to " + value);
- System.setProperty(Context.URL_PKG_PREFIXES, value);
+ LOG.debug( "Setting System Property " + Context.URL_PKG_PREFIXES + " to " + value );
+ System.setProperty( Context.URL_PKG_PREFIXES, value );
- value = System.getProperty(
- Context.INITIAL_CONTEXT_FACTORY);
+ value = System.getProperty( Context.INITIAL_CONTEXT_FACTORY );
- if(value == null)
+ if ( value == null )
{
- System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
- APACHE_INITIAL_CONTEXT_FACTORY);
- LOG.debug("Setting System Property " + Context.INITIAL_CONTEXT_FACTORY + " to " + APACHE_INITIAL_CONTEXT_FACTORY);
+ System.setProperty( Context.INITIAL_CONTEXT_FACTORY,
+ APACHE_INITIAL_CONTEXT_FACTORY );
+ LOG.debug(
+ "Setting System Property " + Context.INITIAL_CONTEXT_FACTORY + " to " +
+ APACHE_INITIAL_CONTEXT_FACTORY );
}
else
{
- LOG.debug("System Property " + Context.INITIAL_CONTEXT_FACTORY + " is set to " + value);
+ LOG.debug( "System Property " + Context.INITIAL_CONTEXT_FACTORY + " is set to " + value );
}
result = new InitialContext();
- if(!ContextBindings.isClassLoaderBound())
+ if ( !ContextBindings.isClassLoaderBound() )
{
- ContextBindings.bindContext("wsrfContext", result);
- ContextBindings.bindClassLoader("wsrfContext");
+ ContextBindings.bindContext( "wsrfContext", result );
+ ContextBindings.bindClassLoader( "wsrfContext" );
}
try
{
- result.lookup("java:comp/env");
+ result.lookup( "java:comp/env" );
}
- catch(NameNotFoundException e)
+ catch ( NameNotFoundException e )
{
- compContext = result.createSubcontext("comp");
- compContext.createSubcontext("env");
+ compContext = result.createSubcontext( "comp" );
+ compContext.createSubcontext( "env" );
}
return result;
}
/**
- * Get the location of the JNDI configuration file from the deployment
- * descriptor
- *
- * @param messageContext The message context to use for discovering
- * deployment information
- * @return Location of JNDI configuration file relative to the root of the
- * installation
- */
- public static String getJNDIConfigFileName(MessageContext messageContext)
- {
- String file = null;
- if(messageContext != null)
- {
- AxisEngine engine = messageContext.getAxisEngine();
- ContainerConfig config = ContainerConfig.getConfig(engine);
- file = config.getOption("jndiConfigFileOption");
- }
- return (file == null) ? "etc/" + JNDI_CONFIG : file;
- }
-
- /**
- * Parse the given JNDI configuration and populate the JNDI registry using
- * the parsed configuration
+ * Parse the given JNDI configuration and populate the JNDI registry using the parsed configuration
*
* @param configInput The configuration stream to parse
+ *
* @throws Exception
*/
- public static void parseJNDIConfig(InputStream configInput)
- throws Exception
+ public static void parseJNDIConfig( InputStream configInput )
+ throws Exception
{
- parseJNDIConfig(new InitialContext(), configInput, null);
+ parseJNDIConfig( new InitialContext(), configInput, null );
}
/**
- * Parse the given JNDI configuration and populate the JNDI registry using
- * the parsed configuration
+ * Parse the given JNDI configuration and populate the JNDI registry using the parsed configuration
*
* @param configInput The configuration stream to parse
+ *
* @throws Exception
*/
- public static void parseJNDIConfig(Context initContext,
- InputStream configInput,
- AxisEngine engine)
- throws Exception
+ public static void parseJNDIConfig( Context initContext,
+ InputStream configInput,
+ AxisEngine engine )
+ throws Exception
{
- if (configInput == null)
+ if ( configInput == null )
{
- throw new IllegalArgumentException(
- "nullJNDIConfigInput");
+ throw new IllegalArgumentException( "nullJNDIConfigInput" );
}
- if (initContext == null)
+ if ( initContext == null )
{
throw new IllegalArgumentException();
}
- Context envContext = (Context) initContext.lookup("java:comp/env");
+ Context envContext = (Context) initContext.lookup( "java:comp/env" );
Digester digester = new Digester();
// Don't do any validation for now
// TODO: Need to write a real schema for this stuff
- digester.setNamespaceAware(true);
- digester.setValidating(false);
- digester.addRuleSet(new JNDIConfigRuleSet("jndiConfig/"));
+ digester.setNamespaceAware( true );
+ digester.setValidating( false );
+ digester.addRuleSet( new JNDIConfigRuleSet( "jndiConfig/" ) );
- digester.push(new NamingContext(envContext, engine));
- digester.parse(configInput);
+ digester.push( new NamingContext( envContext, engine ) );
+ digester.parse( configInput );
digester.clear();
}
/**
- * Retrieves the named object on the specified context. The object returned
- * must be of assignable from the type specified.
+ * Retrieves the named object on the specified context. The object returned must be of assignable from the type
+ * specified.
*
* @param context the context to perform lookup on
* @param name the name of the object to lookup
* @param type the expected type of the object returned
*/
- public static Object lookup(
- Context context,
- String name,
- Class type)
- throws NamingException
+ public static Object lookup( Context context,
+ String name,
+ Class type )
+ throws NamingException
{
- if(context == null)
+ if ( context == null )
{
- throw new IllegalArgumentException(
- "nullArgument:context");
+ throw new IllegalArgumentException( "nullArgument:context" );
}
- if(type == null)
+ if ( type == null )
{
- throw new IllegalArgumentException(
- "nullArgument:type");
+ throw new IllegalArgumentException( "nullArgument:type" );
}
- Object tmp = context.lookup(name);
- if(type.isAssignableFrom(tmp.getClass()))
+ Object tmp = context.lookup( name );
+ if ( type.isAssignableFrom( tmp.getClass() ) )
{
return tmp;
}
else
{
- throw new NamingException(
- "expectedType "+ type.getName());
+ throw new NamingException( "expectedType " + type.getName() );
}
}
- private static class DirFilter implements FileFilter {
- public boolean accept(File path) {
+ private static class DirFilter implements FileFilter
+ {
+ public boolean accept( File path )
+ {
return path.isDirectory();
}
}
// multiple file configuration
- public static synchronized Context initializeDir(MessageContext msgCtx)
- throws Exception
+ public static synchronized Context initializeDir( MessageContext msgCtx )
+ throws Exception
{
- if (initialContext == null)
+ if ( initialContext == null )
{
Context context = initJNDI();
-
- String configProfile =
- (String)msgCtx.getProperty(ContainerConfig.CONFIG_PROFILE);
-
- String configFile = (configProfile == null) ?
- JNDI_CONFIG : configProfile + "-" + JNDI_CONFIG;
-
- String dir =
- (String)msgCtx.getProperty(Constants.MC_CONFIGPATH);
-
- String configDir = (dir == null) ?
- DeployConstants.CONFIG_BASE_DIR :
- dir + File.separator + DeployConstants.CONFIG_BASE_DIR;
-
- File fDir = new File(configDir);
- File [] dirs = fDir.listFiles(new DirFilter());
- for (int i = 0; i < dirs.length; i++)
+ String dir = (String) msgCtx.getProperty( Constants.MC_CONFIGPATH );
+ String configDir = ( dir == null ) ?
+ DeployConstants.CONFIG_BASE_DIR :
+ dir + File.separator + DeployConstants.CONFIG_BASE_DIR;
+
+ File fDir = new File( configDir );
+ File[] dirs = fDir.listFiles( new DirFilter() );
+ for ( int i = 0; i < dirs.length; i++ )
{
- processJNDIFile(context, dirs[i],
- msgCtx.getAxisEngine(), configFile);
+ processJNDIFile( context, dirs[i],
+ msgCtx.getAxisEngine(), JNDI_CONFIG );
}
-
initialContext = context;
}
-
return initialContext;
}
- private static void processJNDIFile(Context context,
- File dir,
- AxisEngine engine,
- String configFile)
- throws Exception
+ private static void processJNDIFile( Context context,
+ File dir,
+ AxisEngine engine,
+ String configFile )
+ throws Exception
{
- File file = new File(dir, configFile);
- if (!file.exists())
+ File file = new File( dir, configFile );
+ if ( !file.exists() )
{
return;
}
- LOG.debug("Loading jndi configuration from file: " + file);
+ LOG.debug( "Loading jndi configuration from file: " + file );
InputStream in = null;
try
{
- in = new FileInputStream(file);
- parseJNDIConfig(context, in, engine);
- }
- finally
+ in = new FileInputStream( file );
+ parseJNDIConfig( context, in, engine );
+ }
+ finally
{
- if (in != null)
+ if ( in != null )
{
- try
+ try
{
in.close();
- }
- catch (IOException e)
+ }
+ catch ( IOException e )
{
}
}
@@ -303,113 +266,103 @@
}
// single file configuration
- public static synchronized Context initializeFile(MessageContext msgCtx)
- throws Exception
+ public static synchronized Context initializeFile( MessageContext msgCtx )
+ throws Exception
{
- if (initialContext == null)
+ if ( initialContext == null )
{
Context context = initJNDI();
InputStream configInput;
- String configFileName =
- JNDIUtils.getJNDIConfigFileName(msgCtx);
try
{
String cfgDir = null;
- if (msgCtx == null)
+ if ( msgCtx != null )
{
- cfgDir = ContainerConfig.getGlobusLocation();
- }
- else
+ cfgDir = (String) msgCtx.getProperty( Constants.MC_CONFIGPATH );
+ }
+ if ( cfgDir == null )
{
- cfgDir = (String)msgCtx.getProperty(Constants.MC_CONFIGPATH);
- if (cfgDir == null)
- {
- cfgDir = ".";
- }
+ cfgDir = ".";
}
- String file = cfgDir + File.separator + configFileName;
- LOG.debug(
- "Trying to load jndi configuration from file: " +
- file);
+ String file = cfgDir + File.separator + JNDI_CONFIG;
+ LOG.debug( "Trying to load JNDI configuration from file: " +
+ file );
- configInput = new FileInputStream(file);
+ configInput = new FileInputStream( file );
}
- catch (FileNotFoundException e)
+ catch ( FileNotFoundException e )
{
- LOG.debug(
- "Trying to load jndi configuration from resource stream: " + configFileName);
+ LOG.debug( "Trying to load JNDI configuration from resource stream: " + JNDI_CONFIG );
configInput =
- JNDIUtils.class.getClassLoader().getResourceAsStream(
- configFileName
- );
+ JNDIUtils.class.getClassLoader().getResourceAsStream( JNDI_CONFIG );
- if (configInput == null)
+ if ( configInput == null )
{
- throw new IOException("jndiConfigNotFound");
+ throw new IOException( "jndiConfigNotFound" );
}
}
- parseJNDIConfig(context, configInput, msgCtx.getAxisEngine());
-
+ parseJNDIConfig( context, configInput, msgCtx.getAxisEngine() );
+
initialContext = context;
}
return initialContext;
}
- public static String toString(Context ctx, String name)
- throws NamingException
+ public static String toString( Context ctx, String name )
+ throws NamingException
{
StringBuffer buf = new StringBuffer();
- toString(buf, ctx, name, "");
+ toString( buf, ctx, name, "" );
return buf.toString();
}
-
- private static void toString(StringBuffer buf, Context ctx,
- String name, String tab)
- throws NamingException
- {
- buf.append(tab).append("context: ").append(name).append("\n");
- NamingEnumeration list = ctx.list(name);
- while (list.hasMore())
+
+ private static void toString( StringBuffer buf, Context ctx,
+ String name, String tab )
+ throws NamingException
+ {
+ buf.append( tab ).append( "context: " ).append( name ).append( "\n" );
+ NamingEnumeration list = ctx.list( name );
+ while ( list.hasMore() )
{
- NameClassPair nc = (NameClassPair)list.next();
- if (nc.getClassName().equals("org.apache.naming.NamingContext"))
+ NameClassPair nc = (NameClassPair) list.next();
+ if ( nc.getClassName().equals( "org.apache.naming.NamingContext" ) )
{
- toString(buf, ctx, name + "/" + nc.getName(), tab + " ");
- }
- else
+ toString( buf, ctx, name + "/" + nc.getName(), tab + " " );
+ }
+ else
{
- buf.append(tab).append(" ").append(nc).append("\n");
+ buf.append( tab ).append( " " ).append( nc ).append( "\n" );
}
}
}
-
+
/**
* Create all intermediate subcontexts.
*/
- public static Context createSubcontexts(Context currentContext,
- String name)
- throws NamingException
+ public static Context createSubcontexts( Context currentContext,
+ String name )
+ throws NamingException
{
- StringTokenizer tokenizer = new StringTokenizer(name, "/");
+ StringTokenizer tokenizer = new StringTokenizer( name, "/" );
- while(tokenizer.hasMoreTokens())
+ while ( tokenizer.hasMoreTokens() )
{
String token = tokenizer.nextToken();
- if((!token.equals("")) && (tokenizer.hasMoreTokens()))
+ if ( ( !token.equals( "" ) ) && ( tokenizer.hasMoreTokens() ) )
{
try
{
- currentContext = currentContext.createSubcontext(token);
+ currentContext = currentContext.createSubcontext( token );
}
- catch(NamingException e)
+ catch ( NamingException e )
{
// Silent catch. Probably an object is already bound in
// the context.
- currentContext = (Context) currentContext.lookup(token);
+ currentContext = (Context) currentContext.lookup( token );
}
}
}
Modified: webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/XmlBeanJndiUtils.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/XmlBeanJndiUtils.java?rev=219275&r1=219274&r2=219275&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/XmlBeanJndiUtils.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/util/jndi/XmlBeanJndiUtils.java Fri Jul 15 18:23:20 2005
@@ -51,570 +51,575 @@
import java.util.List;
import java.util.Set;
-/** LOG-DONE
- * JNDI Utiltiy methods for use with an XmlBean-generated JNDI-Config file.
- * This class handles the initial setup of JNDI, it loads the JNDI config file
- * and registers instances of services.
+/**
+ * LOG-DONE JNDI Utiltiy methods for use with an XmlBean-generated JNDI-Config file. This class handles the initial
+ * setup of JNDI, it loads the JNDI config file and registers instances of services.
*
* @author Sal Campana
*/
public class XmlBeanJndiUtils
- extends JNDIUtils
+ extends JNDIUtils
{
- private static Log LOG = LogFactory.getLog( XmlBeanJndiUtils.class.getName( ) );
+ private static Log LOG = LogFactory.getLog( XmlBeanJndiUtils.class.getName() );
/**
- * Apache JNDI URL Package Prefix
- */
- public static final String APACHE_URL_PKG_PREFIX = "org.apache.naming";
-
- /**
- * Apache JNDI Initial Context Factory Prefix
- */
- public static final String APACHE_INITIAL_CONTEXT_FACTORY =
- "org.apache.naming.java.javaURLContextFactory";
-
- /**
- * Singleton instance of the JNDI Context.
- */
- private static Context m_initialContext;
-
- /**
- * The file name of the jndi-config file.
- */
- public static final String JNDI_CONFIG_FILENAME = "jndi-config.xml";
-
- private static DefaultParameters s_defaultProperties;
- private static final String PROP_FACTORY = "factory";
- private static final String PROP_RESOURCE_KEY_NAME = "resourceKeyName";
- private static final String PROP_RESOURCE_KEY_CLASS_NAME = "resourceKeyClassName";
-
- /**
- * Configure JNDI with the Apache Tomcat naming service classes and create
- * the comp and env contexts
- *
- * @return The initial context
- * @throws Exception
- */
- public static Context initJNDI( )
- throws Exception
- {
- LOG.debug("Initializing JNDI.");
- Context result = null;
- Context compContext = null;
-
- // set up naming
- String apacheUrlPrefix = APACHE_URL_PKG_PREFIX;
- String systemUrlPrefix = System.getProperty( Context.URL_PKG_PREFIXES );
- String systemContextFactory = System.getProperty( Context.INITIAL_CONTEXT_FACTORY );
-
- if(systemContextFactory == null && systemUrlPrefix == null)
- {
- System.setProperty( Context.URL_PKG_PREFIXES, apacheUrlPrefix );
- System.setProperty( Context.INITIAL_CONTEXT_FACTORY, APACHE_INITIAL_CONTEXT_FACTORY );
- }
-
- result = new InitialContext( );
-
- try
- {
- result.lookup( JndiConstants.CONTEXT_NAME_SERVICES );
- }
- catch ( NameNotFoundException e )
- {
- LOG.debug("Creating SubContext: " + JndiConstants.CONTEXT_NAME_BASE);
- compContext = result.createSubcontext( JndiConstants.CONTEXT_NAME_BASE );
- LOG.debug("Creating SubContext: " + JndiConstants.CONTEXT_SERVICES_BASE);
- compContext.createSubcontext( JndiConstants.CONTEXT_SERVICES_BASE );
- LOG.debug("Creating SubContext: " + JndiConstants.CONTEXT_GLOBAL_BASE);
- compContext.createSubcontext( JndiConstants.CONTEXT_GLOBAL_BASE );
- }
-
- return result;
- }
-
- /**
- * Initializes JNDI from a directory tree which contains the
- * jndi-config.xml files....
- *
- * @param configDir
- * @return
- * @throws Exception
- */
- public static synchronized Context initializeDir( String configDir )
- throws Exception
- {
- LOG.debug("Initializing JNDI from root directory: " + configDir);
- if ( m_initialContext == null )
- {
- Context context = initJNDI( );
-
- File fDir = new File( configDir );
- File[] dirs =
- fDir.listFiles( new FileFilter( )
- {
- public boolean accept( File path )
- {
- return path.isDirectory( );
- }
- } );
-
- for ( int i = 0; i < dirs.length; i++ )
- {
- processJNDIFile( context, dirs[i], JNDI_CONFIG_FILENAME );
- }
-
- m_initialContext = context;
- }
-
- return m_initialContext;
- }
-
- /**
- * Initializes JNDI given a File name which will attempt
- * to be loaded.
- *
- * @param configFilename
- * @return
- * @throws Exception
- */
- public static synchronized Context initializeFile( String configFilename )
- throws Exception
- {
- LOG.debug("Initializing JNDI from file: " + configFilename);
- if ( m_initialContext == null )
- {
- Context context = initJNDI( );
-
- InputStream configInput;
- try
- {
- LOG.debug( "Trying to load JNDI configuration from file: " + configFilename );
-
- configInput = new FileInputStream( configFilename );
- }
- catch ( FileNotFoundException fnfe )
- {
- LOG.debug( "Trying to load JNDI configuration from classloader resource: " + configFilename );
-
- configInput = JNDIUtils.class.getClassLoader( ).getResourceAsStream( configFilename );
-
- if ( configInput == null )
- {
- throw new IOException( "jndiConfigNotFound" );
- }
- }
-
- parseJNDIConfig( context, configInput );
-
- m_initialContext = context;
- }
-
- return m_initialContext;
- }
-
- /**
- * Initializes JNDI from a given InputStream to a jndi-config.xml file.
- *
- * @param inputStream
- * @return JNDI Context
- * @throws Exception
- */
- public static synchronized Context initializeFromInputStream( InputStream inputStream )
- throws Exception
- {
- if ( m_initialContext == null )
- {
- Context context = initJNDI( );
-
- LOG.debug( "Trying to load JNDI configuration from inputstream" );
- parseJNDIConfig( context, inputStream );
- m_initialContext = context;
- }
-
- return m_initialContext;
- }
-
- /**
- * Called via parseJNDIConfig(InputStream)
- * <p/>
- * Parse the given JNDI configuration and populate the JNDI registry using
- * the parsed configuration
- *
- * @param configInput The configuration stream to parse
- * @throws Exception
- */
- public static void parseJNDIConfig( Context initContext,
- InputStream configInput )
- throws Exception
- {
- if ( configInput == null )
- {
- throw new IllegalArgumentException( "nullJNDIConfigInput" );
- }
-
- if ( initContext == null )
- {
- throw new IllegalArgumentException( );
- }
-
- //get the global context
- Context envContext = (Context) initContext.lookup( JndiConstants.CONTEXT_NAME_GLOBAL );
- XmlBeanNamingContext namingContext = new XmlBeanNamingContext( envContext );
-
- //load the config file
- JndiConfigDocument configObj = (JndiConfigDocument) XmlObject.Factory.parse( configInput );
- JndiConfigDocument.JndiConfig jndiConfig = configObj.getJndiConfig( );
- GlobalDocument.Global global = jndiConfig.getGlobal( );
-
- //setup the global jndi elements
- addGlobalElements( namingContext, global );
-
- //get the service context
- envContext = (Context) initContext.lookup( JndiConstants.CONTEXT_NAME_SERVICES );
- namingContext = new XmlBeanNamingContext( envContext );
-
- //setup the service jndi elements
- ServiceDocument.Service[] serviceArray = jndiConfig.getServiceArray( );
- addServiceElements( namingContext, serviceArray );
- }
-
- private static DefaultParameters getDefaultProperties( GlobalDocument.Global global )
- throws IllegalAccessException,
- InstantiationException,
- ClassNotFoundException
- {
- ResourceDocument.Resource defaultConfig = null;
- ResourceDocument.Resource[] resourceArray = global.getResourceArray( );
- for ( int i = 0; i < resourceArray.length; i++ )
- {
- ResourceDocument.Resource resource = resourceArray[i];
- if ( DefaultParameters.class.getName( ).equals( resource.getType( ) ) )
- {
- defaultConfig = resource;
- break;
- }
- }
-
- return setupDefaultParams( defaultConfig );
- }
-
- private static Environment[] getEnvironmentArray( EnvironmentDocument.Environment[] environmentArray )
- {
- List envList = new ArrayList( );
-
- if ( environmentArray != null )
- {
- for ( int i = 0; i < environmentArray.length; i++ )
- {
- EnvironmentDocument.Environment environment = environmentArray[i];
- Environment env = new Environment( );
- env.setDescription( environment.getDescription( ) );
- env.setName( environment.getName( ) );
- env.setType( environment.getType( ) );
- env.setValue( environment.getValue( ) );
- envList.add( env );
- }
- }
-
- return (Environment[]) envList.toArray( new Environment[0] );
- }
-
- private static ResourceParameters getParameters( ResourceParamsDocument.ResourceParams resourceParams )
- {
- ResourceParameters params = new ResourceParameters( );
- if ( resourceParams != null )
- {
- ParameterDocument.Parameter[] parameterArray = resourceParams.getParameterArray( );
- for ( int i = 0; i < parameterArray.length; i++ )
- {
- ParameterDocument.Parameter parameter = parameterArray[i];
- params.addParameter( parameter.getName( ), parameter.getValue() );
- }
- }
- return params;
- }
-
- private static void validateParameterValues( ResourceParameters params )
- {
- checkValueIsNonEmpty( params, PROP_FACTORY );
- }
-
- private static void checkValueIsNonEmpty( ResourceParameters params, String paramName )
- {
- String paramValue = params.getParameter( paramName );
- if ( paramValue.trim().equals( "" ) )
- {
- throw new RuntimeException( paramName + " parameter must have a non-empty value!" );
- }
- }
-
- private static void setDefaultParameterValues( ResourceParameters params )
- {
- if ( params.getParameter( PROP_FACTORY ) == null )
- {
- params.addParameter( PROP_FACTORY, s_defaultProperties.getFactory() );
- }
- if ( params.getParameter( PROP_RESOURCE_KEY_CLASS_NAME ) == null )
- {
- params.addParameter( PROP_RESOURCE_KEY_CLASS_NAME, s_defaultProperties.getResourceKeyClassName() );
- }
-
- }
-
- private static Resource[] getResourceArray(ResourceDocument.Resource[] resourceArray, String name, XmlBeanNamingContext namingContext)
- {
- List resources = new ArrayList( );
- if ( resourceArray != null )
- {
- for ( int i = 0; i < resourceArray.length; i++ )
- {
- ResourceDocument.Resource resourceDoc = resourceArray[i];
- //special type of resource....metatdata...handle differently....
- MetadataConfigDocument.MetadataConfig metadataConfig = resourceDoc.getMetadataConfig();
- if (metadataConfig != null)
- {
- try
- {
- Class metaConfigClass = Class.forName(resourceDoc.getType());
- Constructor constructor = metaConfigClass.getClass().getConstructor(new Class[]{metadataConfig.getClass()});
- MetadataConfig metaConfig = (MetadataConfig) constructor.newInstance(new Object[]{metadataConfig});
- String contextName = null;
- if (name != null)
- {
- namingContext.getContext().createSubcontext(name); //add subcontext
- contextName = name + "/";
- }
- contextName = contextName + resourceDoc.getName();
-
- namingContext.bind(contextName, metaConfig);
- continue;
- }
- catch (Exception e)
- {
- LOG.error("Unable to find constructor which takes: " + metadataConfig.getClass().getName() +
- ", in MetadataConfig object: " + resourceDoc.getType() + ". The metadata will be ignored! Cause:" + e);
- }
-
- }
- Resource resource = new Resource( );
- resource.setName( resourceDoc.getName( ) );
- resource.setAuth( resourceDoc.getAuth( ) );
- resource.setDescription( resourceDoc.getDescription( ) );
- resource.setType( resourceDoc.getType( ) );
- resource.setScope( resourceDoc.getScope( ) );
- resource.setParameters( getParameters( resourceDoc.getResourceParams( ) ) );
- resources.add( resource );
- }
- }
-
- return (Resource[]) resources.toArray( new Resource[0] );
- }
-
- private static ResourceLink[] getResourceLinkArray( ResourceLinkDocument.ResourceLink[] resourceLinkArray )
- {
- List resourceLinks = new ArrayList( );
- if ( resourceLinkArray != null )
- {
- for ( int i = 0; i < resourceLinkArray.length; i++ )
- {
- ResourceLinkDocument.ResourceLink resourceLink = resourceLinkArray[i];
- ResourceLink link = new ResourceLink( );
- link.setName( resourceLink.getName( ) );
- link.setTarget( resourceLink.getTarget( ) );
- resourceLinks.add( link );
- }
- }
-
- return (ResourceLink[]) resourceLinks.toArray( new ResourceLink[0] );
- }
-
- private static ConfigContext[] getServiceArray(ServiceDocument.Service[] serviceArray, XmlBeanNamingContext namingContext) throws NamingException
- {
- List services = new ArrayList( );
- if ( serviceArray != null )
- {
- for ( int i = 0; i < serviceArray.length; i++ )
- {
- ServiceDocument.Service service = serviceArray[i];
- ConfigContext context = new ConfigContext( );
- context.setName( service.getName( ) );
- Environment[] environmentArray = getEnvironmentArray( service.getEnvironmentArray( ) );
- for ( int j = 0; j < environmentArray.length; j++ )
- {
- context.addEnvironment( environmentArray[j] );
- }
- Resource[] resourceArray = getResourceArray( service.getResourceArray( ), service.getName(),namingContext );
- for ( int j = 0; j < resourceArray.length; j++ )
- {
- Resource resource = resourceArray[j];
- ResourceParameters params = resource.getParameters();
- setDefaultParameterValues( params );
- validateParameterValues( params );
- }
- for ( int j = 0; j < resourceArray.length; j++ )
- {
- context.addResource( resourceArray[j] );
- }
-
- ResourceLink[] resourceLinkArray = getResourceLinkArray( service.getResourceLinkArray( ) );
- for ( int j = 0; j < resourceLinkArray.length; j++ )
- {
- context.addResourceLink( resourceLinkArray[j] );
- }
-
- services.add( context );
- }
- }
-
- return (ConfigContext[]) services.toArray( new ConfigContext[0] );
- }
-
- private static ConfigContext[] getServiceSubContextArray( ConfigContext service )
- {
- List subContexts = new ArrayList( );
- if ( service != null )
- {
- Set subContextNames = service.getSubContextNames( );
- Iterator iterator = subContextNames.iterator( );
-
- while ( iterator.hasNext( ) )
- {
- subContexts.add( service.getSubContext( (String) iterator.next( ) ) );
- }
- }
-
- return (ConfigContext[]) subContexts.toArray( new ConfigContext[0] );
- }
-
- private static void addGlobalElements( XmlBeanNamingContext namingContext,
- GlobalDocument.Global global )
- throws NamingException,
- IllegalAccessException,
- ClassNotFoundException,
- InstantiationException
- {
- if ( global != null )
- {
- s_defaultProperties = getDefaultProperties( global );
-
- Environment[] environmentArray = getEnvironmentArray( global.getEnvironmentArray( ) );
-
- for ( int i = 0; i < environmentArray.length; i++ )
- {
- namingContext.addEnvironment( environmentArray[i] );
- }
-
- ConfigContext[] subContext = getServiceArray( global.getServiceArray( ),namingContext );
- for ( int i = 0; i < subContext.length; i++ )
- {
- namingContext.addSubContext( subContext[i] );
- }
-
- Resource[] resourceArray = getResourceArray( global.getResourceArray( ), null, namingContext );
- for ( int i = 0; i < resourceArray.length; i++ )
- {
- namingContext.addResource( resourceArray[i] );
- }
-
- ResourceLink[] resourceLinkArray = getResourceLinkArray( global.getResourceLinkArray( ) );
- for ( int i = 0; i < resourceLinkArray.length; i++ )
- {
- namingContext.addResourceLink( resourceLinkArray[i] );
- }
- }
- }
-
- private static void addServiceElements( XmlBeanNamingContext namingContext,
- ServiceDocument.Service[] serviceArray )
- throws NamingException
- {
- if ( serviceArray != null )
- {
- ConfigContext[] services = getServiceArray( serviceArray, namingContext );
- for ( int i = 0; i < services.length; i++ )
- {
- ConfigContext service = services[i];
- namingContext.addService( service );
- ConfigContext[] serviceSubContextArray = getServiceSubContextArray( service );
- for ( int j = 0; j < serviceSubContextArray.length; j++ )
- { //todo not sure if defaults bubble down here...
- namingContext.addSubContext( serviceSubContextArray[j] );
- }
- }
- }
- }
-
- private static void processJNDIFile( Context context,
- File dir,
- String configFile )
- throws Exception
- {
- File file = new File( dir, configFile );
- if ( !file.exists( ) )
- {
- return;
- }
-
- LOG.debug( "Loading JNDI configuration from file: " + file );
-
- InputStream in = null;
- try
- {
- in = new FileInputStream( file );
- parseJNDIConfig( context, in );
- }
- finally
- {
- if ( in != null )
- {
+ * Apache JNDI URL Package Prefix
+ */
+ public static final String APACHE_URL_PKG_PREFIX = "org.apache.naming";
+
+ /**
+ * Apache JNDI Initial Context Factory Prefix
+ */
+ public static final String APACHE_INITIAL_CONTEXT_FACTORY =
+ "org.apache.naming.java.javaURLContextFactory";
+
+ /**
+ * The file name of the jndi-config file.
+ */
+ public static final String JNDI_CONFIG_FILENAME = "jndi-config.xml";
+ private static final String PROP_FACTORY = "factory";
+
+ /**
+ * Singleton instance of the JNDI Context.
+ */
+ private static Context s_wsrfContext;
+
+ private static DefaultParameters s_defaultParams;
+
+ /**
+ * Configure JNDI with the Apache Tomcat naming service classes and create the comp and env contexts
+ *
+ * @return The initial context
+ *
+ * @throws Exception
+ */
+ public static Context initJNDI()
+ throws Exception
+ {
+
+ initJndiImpl();
+ return initWsrfContext();
+ }
+
+ private static Context initWsrfContext()
+ throws NamingException
+ {
+ LOG.debug( "Initializing WSRF JNDI context..." );
+ Context wsrfContext;
+ InitialContext initialContext = new InitialContext();
+ try
+ {
+ wsrfContext = (Context)initialContext.lookup( JndiConstants.CONTEXT_NAME_SERVICES );
+ }
+ catch ( NameNotFoundException nnfe )
+ {
+ LOG.debug( "Creating JNDI subcontext: " + JndiConstants.CONTEXT_NAME_BASE + " ..." );
+ wsrfContext = initialContext.createSubcontext( JndiConstants.CONTEXT_NAME_BASE );
+ LOG.debug( "Creating JNDI subcontext: " + JndiConstants.CONTEXT_SERVICES_BASE + " ..." );
+ wsrfContext.createSubcontext( JndiConstants.CONTEXT_SERVICES_BASE );
+ LOG.debug( "Creating JNDI subcontext: " + JndiConstants.CONTEXT_GLOBAL_BASE + " ..." );
+ wsrfContext.createSubcontext( JndiConstants.CONTEXT_GLOBAL_BASE );
+ }
+ return wsrfContext;
+ }
+
+ private static void initJndiImpl()
+ {
+ String apacheUrlPrefix = APACHE_URL_PKG_PREFIX;
+ String systemUrlPrefix = System.getProperty( Context.URL_PKG_PREFIXES );
+ String systemContextFactory = System.getProperty( Context.INITIAL_CONTEXT_FACTORY );
+
+ if ( systemContextFactory == null && systemUrlPrefix == null )
+ {
+ System.setProperty( Context.URL_PKG_PREFIXES, apacheUrlPrefix );
+ System.setProperty( Context.INITIAL_CONTEXT_FACTORY, APACHE_INITIAL_CONTEXT_FACTORY );
+ }
+ }
+
+ /**
+ * Initializes JNDI from a directory tree which contains the jndi-config.xml files....
+ *
+ * @param configDir
+ *
+ * @return
+ *
+ * @throws Exception
+ */
+ public static synchronized Context initFromDir( String configDir )
+ throws Exception
+ {
+ LOG.debug( "Initializing JNDI from config directory: " + configDir + " ..." );
+ if ( s_wsrfContext == null )
+ {
+ Context context = initJNDI();
+
+ File fDir = new File( configDir );
+ File[] dirs =
+ fDir.listFiles( new FileFilter()
+ {
+ public boolean accept( File path )
+ {
+ return path.isDirectory();
+ }
+ } );
+
+ for ( int i = 0; i < dirs.length; i++ )
+ {
+ processJNDIFile( context, dirs[i], JNDI_CONFIG_FILENAME );
+ }
+
+ s_wsrfContext = context;
+ }
+
+ return s_wsrfContext;
+ }
+
+ /**
+ * Initializes JNDI given a File name which will attempt to be loaded.
+ *
+ * @param configFilename
+ *
+ * @return
+ *
+ * @throws Exception
+ */
+ public static synchronized Context initFromFile( String configFilename )
+ throws Exception
+ {
+ LOG.debug( "Initializing JNDI from file: " + configFilename );
+ if ( s_wsrfContext == null )
+ {
+ Context context = initJNDI();
+
+ InputStream configInput;
try
{
- in.close( );
+ LOG.debug( "Trying to load JNDI configuration from file: " + configFilename );
+
+ configInput = new FileInputStream( configFilename );
+ }
+ catch ( FileNotFoundException fnfe )
+ {
+ LOG.debug( "Trying to load JNDI configuration from classloader resource: " + configFilename );
+
+ configInput = JNDIUtils.class.getClassLoader().getResourceAsStream( configFilename );
+
+ if ( configInput == null )
+ {
+ throw new IOException( "jndiConfigNotFound" );
+ }
+ }
+
+ parseJNDIConfig( context, configInput );
+
+ s_wsrfContext = context;
+ }
+
+ return s_wsrfContext;
+ }
+
+ /**
+ * Initializes JNDI from a given InputStream to a jndi-config.xml file.
+ *
+ * @param inputStream
+ *
+ * @return JNDI Context
+ *
+ * @throws Exception
+ */
+ public static synchronized Context initFromInputStream( InputStream inputStream )
+ throws Exception
+ {
+ if ( s_wsrfContext == null )
+ {
+ Context context = initJNDI();
+ LOG.debug( "Trying to load JNDI configuration from inputstream" );
+ parseJNDIConfig( context, inputStream );
+ s_wsrfContext = context;
+ }
+
+ return s_wsrfContext;
+ }
+
+ /**
+ * Called via parseJNDIConfig(InputStream)
+ * <p/>
+ * Parse the given JNDI configuration and populate the JNDI registry using the parsed configuration
+ *
+ * @param configStream The configuration stream to parse
+ *
+ * @throws Exception
+ */
+ public static void parseJNDIConfig( Context initContext,
+ InputStream configStream )
+ throws Exception
+ {
+ if ( configStream == null )
+ {
+ throw new IllegalArgumentException( "nullJNDIConfigInput" );
+ }
+
+ if ( initContext == null )
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //get the global context
+ Context envContext = (Context) initContext.lookup( JndiConstants.CONTEXT_NAME_GLOBAL );
+ XmlBeanNamingContext namingContext = new XmlBeanNamingContext( envContext );
+
+ //load the config file
+ JndiConfigDocument jndiConfigDoc = (JndiConfigDocument) XmlObject.Factory.parse( configStream );
+ // TODO: validate the JNDI config XMLBean
+ JndiConfigDocument.JndiConfig jndiConfig = jndiConfigDoc.getJndiConfig();
+ GlobalDocument.Global global = jndiConfig.getGlobal();
+
+ //setup the global jndi elements
+ addGlobalElements( namingContext, global );
+
+ //get the service context
+ envContext = (Context) initContext.lookup( JndiConstants.CONTEXT_NAME_SERVICES );
+ namingContext = new XmlBeanNamingContext( envContext );
+
+ //setup the service jndi elements
+ ServiceDocument.Service[] serviceArray = jndiConfig.getServiceArray();
+ addServiceElements( namingContext, serviceArray );
+ }
+
+ private static DefaultParameters getDefaultProperties( GlobalDocument.Global global )
+ throws IllegalAccessException,
+ InstantiationException,
+ ClassNotFoundException
+ {
+ ResourceDocument.Resource defaultConfig = null;
+ ResourceDocument.Resource[] resourceArray = global.getResourceArray();
+ for ( int i = 0; i < resourceArray.length; i++ )
+ {
+ ResourceDocument.Resource resource = resourceArray[i];
+ if ( DefaultParameters.class.getName().equals( resource.getType() ) )
+ {
+ defaultConfig = resource;
+ break;
}
- catch ( IOException e )
+ }
+
+ return setupDefaultParams( defaultConfig );
+ }
+
+ private static Environment[] getEnvironmentArray( EnvironmentDocument.Environment[] environmentArray )
+ {
+ List envList = new ArrayList();
+
+ if ( environmentArray != null )
+ {
+ for ( int i = 0; i < environmentArray.length; i++ )
{
+ EnvironmentDocument.Environment environment = environmentArray[i];
+ Environment env = new Environment();
+ env.setDescription( environment.getDescription() );
+ env.setName( environment.getName() );
+ env.setType( environment.getType() );
+ env.setValue( environment.getValue() );
+ envList.add( env );
}
- }
- }
- }
-
- private static DefaultParameters setupDefaultParams( ResourceDocument.Resource defaultConfig )
- throws ClassNotFoundException,
- IllegalAccessException,
- InstantiationException
- {
- DefaultParameters defaults = null;
- if ( defaultConfig != null )
- {
- Object defaultConf = Class.forName( defaultConfig.getType( ) ).newInstance( );
- if ( defaultConf instanceof DefaultParameters )
- {
- defaults = (DefaultParameters) defaultConf;
+ }
+
+ return (Environment[]) envList.toArray( new Environment[0] );
+ }
- ResourceParamsDocument.ResourceParams resourceParams = defaultConfig.getResourceParams( );
- ParameterDocument.Parameter[] parameterArray = resourceParams.getParameterArray( );
+ private static ResourceParameters getParameters( ResourceParamsDocument.ResourceParams resourceParams )
+ {
+ ResourceParameters params = new ResourceParameters();
+ if ( resourceParams != null )
+ {
+ ParameterDocument.Parameter[] parameterArray = resourceParams.getParameterArray();
for ( int i = 0; i < parameterArray.length; i++ )
{
- ParameterDocument.Parameter parameter = parameterArray[i];
- String name = parameter.getName( );
- String value = parameter.getValue( );
-
- if ( ( value != null ) && !value.equals( "" ) )
- {
- if ( PROP_FACTORY.equals( name ) )
- {
- defaults.setFactory( value );
- }
- else if ( PROP_RESOURCE_KEY_CLASS_NAME.equals( name ) )
- {
- defaults.setResourceKeyClassName( value );
- }
- }
+ ParameterDocument.Parameter parameter = parameterArray[i];
+ params.addParameter( parameter.getName(), parameter.getValue() );
}
- }
- }
+ }
+ return params;
+ }
+
+ private static void validateParameterValues( ResourceParameters params )
+ {
+ checkValueIsNonEmpty( params, PROP_FACTORY );
+ }
+
+ private static void checkValueIsNonEmpty( ResourceParameters params, String paramName )
+ {
+ String paramValue = params.getParameter( paramName );
+ if ( paramValue.trim().equals( "" ) )
+ {
+ throw new RuntimeException( paramName + " parameter must have a non-empty value!" );
+ }
+ }
+
+ private static void setDefaultParameterValues( ResourceParameters params )
+ {
+ if ( params.getParameter( PROP_FACTORY ) == null )
+ {
+ params.addParameter( PROP_FACTORY, s_defaultParams.getFactory() );
+ }
+ }
+
+ private static Resource[] getResourceArray( ResourceDocument.Resource[] resourceArray, String name,
+ XmlBeanNamingContext namingContext )
+ {
+ List resources = new ArrayList();
+ if ( resourceArray != null )
+ {
+ for ( int i = 0; i < resourceArray.length; i++ )
+ {
+ ResourceDocument.Resource resourceDoc = resourceArray[i];
+ //special type of resource....metatdata...handle differently....
+ MetadataConfigDocument.MetadataConfig metadataConfig = resourceDoc.getMetadataConfig();
+ if ( metadataConfig != null )
+ {
+ try
+ {
+ Class metaConfigClass = Class.forName( resourceDoc.getType() );
+ Constructor constructor = metaConfigClass.getClass().getConstructor(
+ new Class[]{metadataConfig.getClass()} );
+ MetadataConfig metaConfig = (MetadataConfig) constructor.newInstance(
+ new Object[]{metadataConfig} );
+ String contextName = null;
+ if ( name != null )
+ {
+ namingContext.getContext().createSubcontext( name ); //add subcontext
+ contextName = name + "/";
+ }
+ contextName = contextName + resourceDoc.getName();
+
+ namingContext.bind( contextName, metaConfig );
+ continue;
+ }
+ catch ( Exception e )
+ {
+ LOG.error(
+ "Unable to find constructor which takes: " + metadataConfig.getClass().getName() +
+ ", in MetadataConfig object: " +
+ resourceDoc.getType() +
+ ". The metadata will be ignored! Cause:" +
+ e );
+ }
+
+ }
+ Resource resource = new Resource();
+ resource.setName( resourceDoc.getName() );
+ resource.setAuth( resourceDoc.getAuth() );
+ resource.setDescription( resourceDoc.getDescription() );
+ resource.setType( resourceDoc.getType() );
+ resource.setScope( resourceDoc.getScope() );
+ resource.setParameters( getParameters( resourceDoc.getResourceParams() ) );
+ resources.add( resource );
+ }
+ }
+
+ return (Resource[]) resources.toArray( new Resource[0] );
+ }
+
+ private static ResourceLink[] getResourceLinkArray( ResourceLinkDocument.ResourceLink[] resourceLinkArray )
+ {
+ List resourceLinks = new ArrayList();
+ if ( resourceLinkArray != null )
+ {
+ for ( int i = 0; i < resourceLinkArray.length; i++ )
+ {
+ ResourceLinkDocument.ResourceLink resourceLink = resourceLinkArray[i];
+ ResourceLink link = new ResourceLink();
+ link.setName( resourceLink.getName() );
+ link.setTarget( resourceLink.getTarget() );
+ resourceLinks.add( link );
+ }
+ }
+ return (ResourceLink[]) resourceLinks.toArray( new ResourceLink[0] );
+ }
+
+ private static ConfigContext[] getServiceArray( ServiceDocument.Service[] serviceArray,
+ XmlBeanNamingContext namingContext )
+ {
+ List services = new ArrayList();
+ if ( serviceArray != null )
+ {
+ for ( int i = 0; i < serviceArray.length; i++ )
+ {
+ ServiceDocument.Service service = serviceArray[i];
+ ConfigContext context = new ConfigContext();
+ context.setName( service.getName() );
+ Environment[] environmentArray = getEnvironmentArray( service.getEnvironmentArray() );
+ for ( int j = 0; j < environmentArray.length; j++ )
+ {
+ context.addEnvironment( environmentArray[j] );
+ }
+ Resource[] resourceArray = getResourceArray( service.getResourceArray(), service.getName(),
+ namingContext );
+ for ( int j = 0; j < resourceArray.length; j++ )
+ {
+ Resource resource = resourceArray[j];
+ ResourceParameters params = resource.getParameters();
+ setDefaultParameterValues( params );
+ validateParameterValues( params );
+ }
+ for ( int j = 0; j < resourceArray.length; j++ )
+ {
+ context.addResource( resourceArray[j] );
+ }
+
+ ResourceLink[] resourceLinkArray = getResourceLinkArray( service.getResourceLinkArray() );
+ for ( int j = 0; j < resourceLinkArray.length; j++ )
+ {
+ context.addResourceLink( resourceLinkArray[j] );
+ }
+
+ services.add( context );
+ }
+ }
+
+ return (ConfigContext[]) services.toArray( new ConfigContext[0] );
+ }
- return defaults;
- }
+ private static ConfigContext[] getServiceSubContextArray( ConfigContext service )
+ {
+ List subContexts = new ArrayList();
+ if ( service != null )
+ {
+ Set subContextNames = service.getSubContextNames();
+ Iterator iterator = subContextNames.iterator();
+
+ while ( iterator.hasNext() )
+ {
+ subContexts.add( service.getSubContext( (String) iterator.next() ) );
+ }
+ }
+
+ return (ConfigContext[]) subContexts.toArray( new ConfigContext[0] );
+ }
+
+ private static void addGlobalElements( XmlBeanNamingContext namingContext,
+ GlobalDocument.Global global )
+ throws NamingException,
+ IllegalAccessException,
+ ClassNotFoundException,
+ InstantiationException
+ {
+ if ( global != null )
+ {
+ s_defaultParams = getDefaultProperties( global );
+
+ Environment[] environmentArray = getEnvironmentArray( global.getEnvironmentArray() );
+
+ for ( int i = 0; i < environmentArray.length; i++ )
+ {
+ namingContext.addEnvironment( environmentArray[i] );
+ }
+
+ ConfigContext[] subContext = getServiceArray( global.getServiceArray(), namingContext );
+ for ( int i = 0; i < subContext.length; i++ )
+ {
+ namingContext.addSubContext( subContext[i] );
+ }
+
+ Resource[] resourceArray = getResourceArray( global.getResourceArray(), null, namingContext );
+ for ( int i = 0; i < resourceArray.length; i++ )
+ {
+ namingContext.addResource( resourceArray[i] );
+ }
+
+ ResourceLink[] resourceLinkArray = getResourceLinkArray( global.getResourceLinkArray() );
+ for ( int i = 0; i < resourceLinkArray.length; i++ )
+ {
+ namingContext.addResourceLink( resourceLinkArray[i] );
+ }
+ }
+ }
+
+ private static void addServiceElements( XmlBeanNamingContext namingContext,
+ ServiceDocument.Service[] serviceArray )
+ throws NamingException
+ {
+ if ( serviceArray != null )
+ {
+ ConfigContext[] services = getServiceArray( serviceArray, namingContext );
+ for ( int i = 0; i < services.length; i++ )
+ {
+ ConfigContext service = services[i];
+ namingContext.addService( service );
+ ConfigContext[] serviceSubContextArray = getServiceSubContextArray( service );
+ for ( int j = 0; j < serviceSubContextArray.length; j++ )
+ { //todo not sure if defaults bubble down here...
+ namingContext.addSubContext( serviceSubContextArray[j] );
+ }
+ }
+ }
+ }
+
+ private static void processJNDIFile( Context context,
+ File dir,
+ String configFile )
+ throws Exception
+ {
+ File file = new File( dir, configFile );
+ if ( !file.exists() )
+ {
+ return;
+ }
+
+ LOG.debug( "Loading JNDI configuration from file: " + file + " ..." );
+
+ InputStream in = null;
+ try
+ {
+ in = new FileInputStream( file );
+ parseJNDIConfig( context, in );
+ }
+ finally
+ {
+ if ( in != null )
+ {
+ try
+ {
+ in.close();
+ }
+ catch ( IOException ioe )
+ {
+ // ignore
+ }
+ }
+ }
+ }
+
+ private static DefaultParameters setupDefaultParams( ResourceDocument.Resource defaultConfig )
+ throws ClassNotFoundException,
+ IllegalAccessException,
+ InstantiationException
+ {
+ DefaultParameters defaultParams = null;
+ if ( defaultConfig != null )
+ {
+ Object defaultConf = Class.forName( defaultConfig.getType() ).newInstance();
+ if ( defaultConf instanceof DefaultParameters )
+ {
+ defaultParams = (DefaultParameters) defaultConf;
+ ResourceParamsDocument.ResourceParams resourceParams = defaultConfig.getResourceParams();
+ ParameterDocument.Parameter[] parameterArray = resourceParams.getParameterArray();
+ for ( int i = 0; i < parameterArray.length; i++ )
+ {
+ ParameterDocument.Parameter parameter = parameterArray[i];
+ String name = parameter.getName();
+ String value = parameter.getValue();
+
+ if ( ( value != null ) && !value.equals( "" ) )
+ {
+ if ( PROP_FACTORY.equals( name ) )
+ {
+ defaultParams.setFactory( value );
+ }
+ }
+ }
+ }
+ }
+ return defaultParams;
+ }
}
Added: webservices/wsrf/trunk/src/site/cwiki_quickref.htm
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/site/cwiki_quickref.htm?rev=219275&view=auto
==============================================================================
--- webservices/wsrf/trunk/src/site/cwiki_quickref.htm (added)
+++ webservices/wsrf/trunk/src/site/cwiki_quickref.htm Fri Jul 15 18:23:20 2005
@@ -0,0 +1,21 @@
+<pre>
+<b>----</b> = Make a horizontal ruler. Extra '-' is ignored.
+<b>\\</b> = force a line break, \\\=force line break and clear.
+<b>[link]</b> = creates a hyperlink to an internal WikiPage called 'Link'.
+<b>[another link]</b> = creates a hyperlink to an internal WikiPage called 'AnotherLink'.
+<b>[click here|link]</b> = creates a hyperlink to an internal WikiPage called 'Link', but displays the text 'click here' to the user instead of 'Link'.
+<b>[1]</b> = Makes a reference to a footnote numbered 1.
+<b>[#1]</b> = Marks the footnote number 1.
+<b>[[link]</b> = creates text '[link]'
+<b>!heading</b> = small heading with text 'heading'
+<b>!!heading</b> = medium heading with text 'heading'
+<b>!!!heading</b> = large heading with text 'heading'
+<b>''text''</b> = prints 'text' in italic.
+<b>__text__</b> = prints 'text' in bold.
+<b>{{text}}</b> = prints 'text' in monospaced font.
+<b>* text</b> = makes a bulleted list item with 'text'
+<b># text</b> = makes a numbered list item with 'text'
+<b>;term:ex</b> = makes a definition for 'term' with the explanation 'ex'
+</pre>
+
+<b>Note:</b> Be careful with the hierarchy of headings, e.g. do not jump from level-3 to level-1.
Modified: webservices/wsrf/trunk/src/templates/jndi.vm
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/templates/jndi.vm?rev=219275&r1=219274&r2=219275&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/templates/jndi.vm (original)
+++ webservices/wsrf/trunk/src/templates/jndi.vm Fri Jul 15 18:23:20 2005
@@ -23,16 +23,13 @@
<parameter>
<name>wsdlTargetNamespace</name>
<value>${namespace}</value>
- </parameter>
-
+ </parameter>
#if($resourcekey)
<parameter>
- <name>resourceKeyName</name>
+ <name>resourceIdentifierReferenceParameterName</name>
<value>{${resourcekey.NamespaceURI}}${resourcekey.LocalPart}</value>
- </parameter>
-
+ </parameter>
#end
-
</resourceParams>
</resource>
</service>