Bill
Here’s a partial patch for implementing the wsdl console extension using MEX, like we talked about on
the last DC call. I think this’ll get you pretty close – you should
just need to print the wsdl that’s returned (it’s
a W3C element).
Cheers,
Joel
P.S. I’ve made a few changes to the WSDM binding to
make deal with WsResources rather than WSDMBindings – I’ll be checking those in
against the WSDL bug, in preparation for handling muse-generated resources. You
won’t need them to move this forward, so no need to wait on me.
### Eclipse Workspace Patch 1.0
#P org.eclipse.cosmos.dc.common
Index: src/org/eclipse/cosmos/dc/common/ConsoleExtension.java
===================================================================
RCS file:
/cvsroot/technology/org.eclipse.cosmos/data-collection/org.eclipse.cosmos.dc.common/src/org/eclipse/cosmos/dc/common/ConsoleExtension.java,v
retrieving revision
1.9
diff -u -r1.9 ConsoleExtension.java
--- src/org/eclipse/cosmos/dc/common/ConsoleExtension.java 30 Aug 2007 01:11:02 -0000 1.9
+++ src/org/eclipse/cosmos/dc/common/ConsoleExtension.java 31 Aug 2007 13:52:59 -0000
@@ -24,7 +24,9 @@
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
+import org.w3c.dom.Element;
import org.eclipse.osgi.framework.console.CommandInterpreter;
import org.eclipse.osgi.framework.console.CommandProvider;
import org.eclipse.cosmos.dc.common.api.IDataCollectionContext;
@@ -39,13 +41,23 @@
import org.eclipse.cosmos.dc.common.spi.OutboundContext;
import org.eclipse.cosmos.dc.common.spi.RuntimeHost;
import org.eclipse.cosmos.dc.common.spi.ServiceRegistry;
+import org.eclipse.cosmos.dc.mgmt.binding.Binding;
import org.eclipse.cosmos.dc.mgmt.common.ContributionManager;
import org.eclipse.cosmos.dc.runtime.Runtime;
+import org.apache.muse.ws.addressing.EndpointReference;
+import org.apache.muse.ws.metadata.remote.MetadataExchangeClient;
+import org.apache.muse.ws.resource.WsResource;
+
+
+
public class ConsoleExtension
implements CommandProvider {
- BundleContext context;
+ private BundleContext context;
+ private Binding wsdmBinding =
null;
+
+ private static final String BINDING_FILTER = "(&(objectclass=org.eclipse.cosmos.dc.mgmt.binding.Binding)(Provider=WSDM))";
private static RuntimeHost
runtime;
@@ -207,6 +219,22 @@
System.out.println( "
" + element );
}
}
+ }else if("wsdl".equals(name)){
+ EndpointReference epr = null;
+ IDataCollectionContext ctx = runtime.getContextForName(name);
+ if(wsdmBinding == null) wsdmBinding = getWSDMBinding();
+ if(wsdmBinding == null){
+ System.out.println("Unable to resolve metadata");
+ return;
+ }
+ WsResource resource = (WsResource)wsdmBinding.getBindingForObject(ctx);
+ if(resource != null){
+ epr = resource.getEndpointReference();
+ MetadataExchangeClient mex = new MetadataExchangeClient(epr);
+ Element
elem = mex.getWSDL();
+ }
else {
+ System.out.print("resource
not found");
+ }
}
}
}
@@ -249,5 +277,15 @@
return null;
}
+ private Binding getWSDMBinding(){
+ try
{
+ ServiceReference[]
refs = context.getServiceReferences("org.eclipse.cosmos.dc.mgmt.binding.Binding", BINDING_FILTER);
+ if(refs != null && refs.length
> 0){
+ return
(Binding)context.getService(refs[0]);
+ }
+ }
catch (InvalidSyntaxException e) {
+ }
+ return
null;
+ }
}
Index: META-INF/MANIFEST.MF
===================================================================
RCS file:
/cvsroot/technology/org.eclipse.cosmos/data-collection/org.eclipse.cosmos.dc.common/META-INF/MANIFEST.MF,v
retrieving revision
1.17
diff -u -r1.17
MANIFEST.MF
--- META-INF/MANIFEST.MF 3 Aug 2007 16:56:55 -0000 1.17
+++ META-INF/MANIFEST.MF 31 Aug 2007 13:52:59 -0000
@@ -29,7 +29,8 @@
org.eclipse.cosmos.dc.common.spi;version="1.0.0",
org.eclipse.cosmos.dc.common.spi.descriptor;version="1.0.0",
org.eclipse.cosmos.dc.runtime;version="1.0.0"
-Require-Bundle: org.eclipse.cosmos.dc.mgmt.common;visibility:=reexport
+Require-Bundle: org.eclipse.cosmos.dc.mgmt.common;visibility:=reexport,
+ org.apache.muse.complete
Eclipse-LazyStart: true
Service-Component: META-INF/DCRuntime.xml
Bundle-ClassPath: .