diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-08-29 02:46:21 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-08-29 02:46:21 +0000 |
commit | 490374326cf57b0161d053aea3a9f0cedd7d2228 (patch) | |
tree | 1a0dc011461aef099bf3fe33165b45a9ba492680 /sca-java-2.x/trunk/modules/implementation-python-runtime/src/main/java | |
parent | 460613d0d5e60b9ed43094220b89dd31388463c2 (diff) |
Minor change. Code format and cleanup.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@990478 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/implementation-python-runtime/src/main/java')
3 files changed, 39 insertions, 39 deletions
diff --git a/sca-java-2.x/trunk/modules/implementation-python-runtime/src/main/java/org/apache/tuscany/sca/implementation/python/provider/PythonImplementationProvider.java b/sca-java-2.x/trunk/modules/implementation-python-runtime/src/main/java/org/apache/tuscany/sca/implementation/python/provider/PythonImplementationProvider.java index 0c9c1a2240..7d381ac9d9 100644 --- a/sca-java-2.x/trunk/modules/implementation-python-runtime/src/main/java/org/apache/tuscany/sca/implementation/python/provider/PythonImplementationProvider.java +++ b/sca-java-2.x/trunk/modules/implementation-python-runtime/src/main/java/org/apache/tuscany/sca/implementation/python/provider/PythonImplementationProvider.java @@ -43,7 +43,7 @@ import org.python.util.PythonInterpreter; /** * Implementation provider for Python component implementations. - * + * * @version $Rev$ $Date$ */ class PythonImplementationProvider implements ImplementationProvider { @@ -52,7 +52,7 @@ class PythonImplementationProvider implements ImplementationProvider { PythonInterpreter python; PyObject callable; ProxyFactory pxFactory; - + PythonImplementationProvider(final RuntimeComponent comp, final PythonImplementation impl, ProxyFactory pxf) { component = comp; implementation = impl; @@ -60,40 +60,40 @@ class PythonImplementationProvider implements ImplementationProvider { } public void start() { - final PySystemState pss = new PySystemState(); - pss.path.insert(0, new PyString(implementation.getLocation())); - pss.path.insert(0, new PyString(getClass().getProtectionDomain().getCodeSource().getLocation().getFile())); - python = new PythonInterpreter(null, pss); - python.exec("from invoker import *"); - - final List<PyObject> px = new ArrayList<PyObject>(); - for (final ComponentReference r: component.getReferences()) { - final PythonEval pe = pxFactory.createProxy(PythonEval.class, (RuntimeEndpointReference)r.getEndpointReferences().get(0)); + final PySystemState pss = new PySystemState(); + pss.path.insert(0, new PyString(implementation.getLocation())); + pss.path.insert(0, new PyString(getClass().getProtectionDomain().getCodeSource().getLocation().getFile())); + python = new PythonInterpreter(null, pss); + python.exec("from invoker import *"); + + final List<PyObject> px = new ArrayList<PyObject>(); + for(final ComponentReference r: component.getReferences()) { + final PythonEval pe = pxFactory.createProxy(PythonEval.class, (RuntimeEndpointReference)r.getEndpointReferences().get(0)); px.add(Py.java2py(new PythonEval() { - @Override - public String eval(final String args) throws Exception { - final String v = pe.eval(args); - return v; - } + @Override + public String eval(final String args) throws Exception { + final String v = pe.eval(args); + return v; + } })); - } - final List<PyObject> pr = new ArrayList<PyObject>(); - for (final ComponentProperty p: component.getProperties()) { - final String v = String.valueOf(p.getValue()); + } + final List<PyObject> pr = new ArrayList<PyObject>(); + for(final ComponentProperty p: component.getProperties()) { + final String v = String.valueOf(p.getValue()); pr.add(Py.java2py(new PythonProperty() { - @Override - public String eval() { - return v; - } - })); - } + @Override + public String eval() { + return v; + } + })); + } - PyObject mkc = python.get("mkcomponent"); - callable = mkc.__call__(new PyString(component.getName()), new PyString(implementation.getScript()), new PyTuple(px.toArray(new PyObject[0])), new PyTuple(pr.toArray(new PyObject[0]))); + PyObject mkc = python.get("mkcomponent"); + callable = mkc.__call__(new PyString(component.getName()), new PyString(implementation.getScript()), new PyTuple(px.toArray(new PyObject[0])), new PyTuple(pr.toArray(new PyObject[0]))); } public void stop() { - python.cleanup(); + python.cleanup(); } public boolean supportsOneWayInvocation() { diff --git a/sca-java-2.x/trunk/modules/implementation-python-runtime/src/main/java/org/apache/tuscany/sca/implementation/python/provider/PythonImplementationProviderFactory.java b/sca-java-2.x/trunk/modules/implementation-python-runtime/src/main/java/org/apache/tuscany/sca/implementation/python/provider/PythonImplementationProviderFactory.java index 1a09e1cc99..752e3fd899 100644 --- a/sca-java-2.x/trunk/modules/implementation-python-runtime/src/main/java/org/apache/tuscany/sca/implementation/python/provider/PythonImplementationProviderFactory.java +++ b/sca-java-2.x/trunk/modules/implementation-python-runtime/src/main/java/org/apache/tuscany/sca/implementation/python/provider/PythonImplementationProviderFactory.java @@ -29,20 +29,20 @@ import org.apache.tuscany.sca.runtime.RuntimeComponent; /** * A factory for Python implementation providers. - * + * * @version $Rev$ $Date$ */ public class PythonImplementationProviderFactory implements ImplementationProviderFactory<PythonImplementation> { - final ProxyFactory pxFactory; - + final ProxyFactory pxFactory; + public PythonImplementationProviderFactory(final ExtensionPointRegistry ep) { - pxFactory = ExtensibleProxyFactory.getInstance(ep); + pxFactory = ExtensibleProxyFactory.getInstance(ep); } public ImplementationProvider createImplementationProvider(final RuntimeComponent comp, final PythonImplementation impl) { return new PythonImplementationProvider(comp, impl, pxFactory); } - + public Class<PythonImplementation> getModelType() { return PythonImplementation.class; } diff --git a/sca-java-2.x/trunk/modules/implementation-python-runtime/src/main/java/org/apache/tuscany/sca/implementation/python/provider/PythonInvoker.java b/sca-java-2.x/trunk/modules/implementation-python-runtime/src/main/java/org/apache/tuscany/sca/implementation/python/provider/PythonInvoker.java index da342bd03c..a49e5e3296 100644 --- a/sca-java-2.x/trunk/modules/implementation-python-runtime/src/main/java/org/apache/tuscany/sca/implementation/python/provider/PythonInvoker.java +++ b/sca-java-2.x/trunk/modules/implementation-python-runtime/src/main/java/org/apache/tuscany/sca/implementation/python/provider/PythonInvoker.java @@ -28,7 +28,7 @@ import org.python.util.PythonInterpreter; /** * An invoker for Python components. - * + * * @version $Rev$ $Date$ */ class PythonInvoker implements Invoker { @@ -43,15 +43,15 @@ class PythonInvoker implements Invoker { } String apply(final String req) { - PyObject r = callable.__call__(new PyString(req)); - return r.toString(); + PyObject r = callable.__call__(new PyString(req)); + return r.toString(); } public Message invoke(final Message msg) { try { msg.setBody(apply((String)((Object[])msg.getBody())[0])); - } catch (Exception e) { - e.printStackTrace(); + } catch(Exception e) { + e.printStackTrace(); msg.setFaultBody(e.getCause()); } return msg; |