You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by er...@apache.org on 2005/11/24 14:20:13 UTC
svn commit: r348724 - in
/directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs:
JNDIClassLoader.java JavaStoredProcedure.java LdapClassLoader.java
StoredProcedure.java
Author: ersiner
Date: Thu Nov 24 05:20:05 2005
New Revision: 348724
URL: http://svn.apache.org/viewcvs?rev=348724&view=rev
Log:
Added a full stored proc runner using the preiously implemented ldap class loader.
Added:
directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/JavaStoredProcedure.java
directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/LdapClassLoader.java
- copied, changed from r348696, directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/JNDIClassLoader.java
directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/StoredProcedure.java
Removed:
directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/JNDIClassLoader.java
Added: directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/JavaStoredProcedure.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/JavaStoredProcedure.java?rev=348724&view=auto
==============================================================================
--- directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/JavaStoredProcedure.java (added)
+++ directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/JavaStoredProcedure.java Thu Nov 24 05:20:05 2005
@@ -0,0 +1,85 @@
+/*
+ * 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.ldap.server.storedprocs;
+
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.ldap.server.jndi.ServerLdapContext;
+
+/**
+ * Default implementation of StoredProcedure Interface.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$ $Date$
+ */
+public class JavaStoredProcedure implements StoredProcedure
+{
+ ServerLdapContext ctx;
+ String fQSPName;
+ Class[] parameterTypes;
+ Method method;
+ Class methodClass;
+
+ public JavaStoredProcedure(
+ ServerLdapContext ctx,
+ String fullyQualifiedSPName,
+ Class[] parameterTypes ) throws ClassNotFoundException, SecurityException, NoSuchMethodException
+ {
+ this.ctx = ctx;
+ this.fQSPName = fullyQualifiedSPName;
+ this.parameterTypes = parameterTypes;
+
+ methodClass = new LdapClassLoader( this.ctx ).loadClass( getFqClassNameFromFqSPName( this.fQSPName ) );
+
+ this.method = methodClass.getMethod( getSPNameFromFqSPName( this.fQSPName ), this.parameterTypes );
+ }
+
+ private String getFqClassNameFromFqSPName( String fqSPName )
+ {
+ return fqSPName.substring( 0 , fqSPName.lastIndexOf( '.' ) );
+ }
+
+ private String getSPNameFromFqSPName( String fqSPName )
+ {
+ return fqSPName.substring( fqSPName.lastIndexOf( '.' ) + 1 );
+ }
+
+ public Object call( Object[] parameterValues ) throws InvocationTargetException
+ {
+ Object returnValue = null;
+
+ try
+ {
+ returnValue = method.invoke( null, parameterValues );
+ }
+ catch (IllegalArgumentException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ catch (IllegalAccessException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return returnValue;
+ }
+}
Copied: directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/LdapClassLoader.java (from r348696, directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/JNDIClassLoader.java)
URL: http://svn.apache.org/viewcvs/directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/LdapClassLoader.java?p2=directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/LdapClassLoader.java&p1=directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/JNDIClassLoader.java&r1=348696&r2=348724&rev=348724&view=diff
==============================================================================
--- directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/JNDIClassLoader.java (original)
+++ directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/LdapClassLoader.java Thu Nov 24 05:20:05 2005
@@ -35,19 +35,18 @@
/**
- * A class loader that loads classes from an LDAP DIT entry
- * with objectClass javaClass.
+ * A class loader that loads classes from an LDAP DIT.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class JNDIClassLoader extends ClassLoader
+public class LdapClassLoader extends ClassLoader
{
- private static final Logger log = LoggerFactory.getLogger( JNDIClassLoader.class );
+ private static final Logger log = LoggerFactory.getLogger( LdapClassLoader.class );
private ServerLdapContext ctx;
- public JNDIClassLoader( ServerLdapContext ctx )
+ public LdapClassLoader( ServerLdapContext ctx )
{
this.ctx = ctx;
}
@@ -55,7 +54,7 @@
public Class findClass( String name ) throws ClassNotFoundException
{
- byte[] b = null;
+ byte[] classBytes = null;
BranchNode filter = new BranchNode( BranchNode.AND );
filter.addNode( new SimpleNode( "fqcn", name, LeafNode.EQUALITY ) );
@@ -71,7 +70,7 @@
{
SearchResult result = ( SearchResult ) list.next();
Attribute byteCode = result.getAttributes().get( "byteCode" );
- b = ( byte[] ) byteCode.get();
+ classBytes = ( byte[] ) byteCode.get();
}
else
{
@@ -91,6 +90,6 @@
if ( list != null ) { try { list.close(); } catch( Exception e ) {} };
}
- return defineClass( name, b, 0, b.length );
+ return defineClass( name, classBytes, 0, classBytes.length );
}
}
Added: directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/StoredProcedure.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/StoredProcedure.java?rev=348724&view=auto
==============================================================================
--- directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/StoredProcedure.java (added)
+++ directory/sandbox/ersiner/apacheds-with-storedprocs/core/src/main/java/org/apache/ldap/server/storedprocs/StoredProcedure.java Thu Nov 24 05:20:05 2005
@@ -0,0 +1,26 @@
+/*
+ * 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.ldap.server.storedprocs;
+
+import java.lang.reflect.InvocationTargetException;
+
+public interface StoredProcedure
+{
+ Object call( Object[] parameterValues ) throws InvocationTargetException;
+}