You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2007/05/07 03:02:09 UTC
svn commit: r535701 - in /incubator/tuscany/java/sca:
modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/
modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/
modules/host-embedded/src/test/java/org/apache/tuscan...
Author: jsdelfino
Date: Sun May 6 18:02:07 2007
New Revision: 535701
URL: http://svn.apache.org/viewvc?view=rev&rev=535701
Log:
Cleaned up host-embedded, removed unused classes. Added a bean variant of SCADomain for use in environments where a bean is more convenient that a factory with newInstance.
Added:
incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SCADomainBean.java (with props)
incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/SCADomainBeanTestCase.java (with props)
incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/SCADomainTestCase.java (with props)
incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/impl/DefaultSCADomainTestCase.java (with props)
Removed:
incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SCARuntime.java
incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SCARuntimeActivator.java
incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/DefaultSCARuntime.java
incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/DefaultSCARuntimeActivator.java
incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/MiniRuntimeImpl.java
incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/SimpleCompositeContextImpl.java
incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/SimpleRuntimeInfo.java
incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/SimpleRuntimeInfoImpl.java
incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/SCARuntimeTestCase.java
incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/impl/SimpleRuntimeImplTestCase.java
Modified:
incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SCADomain.java
incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/DefaultSCADomain.java
incubator/tuscany/java/sca/samples/helloworld-wsclient/src/test/java/helloworld/HelloWorldClientTestCase.java
Modified: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SCADomain.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SCADomain.java?view=diff&rev=535701&r1=535700&r2=535701
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SCADomain.java (original)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SCADomain.java Sun May 6 18:02:07 2007
@@ -49,7 +49,7 @@
* @return
*/
public static SCADomain newInstance(String domainURI, String contributionLocation, String...composites) {
- return newInstance(SCADomain.class.getClassLoader(), domainURI, contributionLocation, composites);
+ return createNewInstance(domainURI, contributionLocation, composites);
}
/**
@@ -70,7 +70,7 @@
* @return
*/
public static SCADomain newInstance(String composite) {
- return newInstance(SCADomain.class.getClassLoader(), "http://localhost", ".", composite);
+ return createNewInstance("http://localhost", ".", composite);
}
/**
@@ -166,11 +166,12 @@
* @param composites
* @return
*/
- private static SCADomain newInstance(
- final ClassLoader classLoader,
- String domainURI, String contributionLocation, String...composites) {
+ static SCADomain createNewInstance(String domainURI, String contributionLocation, String...composites) {
try {
+ final ClassLoader runtimeClassLoader = SCADomain.class.getClassLoader();
+ final ClassLoader applicationClassLoader = Thread.currentThread().getContextClassLoader();
+
final String name = SCADomain.class.getName();
String className = AccessController.doPrivileged(new PrivilegedAction<String>() {
public String run() {
@@ -179,14 +180,17 @@
});
if (className == null) {
- className = getServiceName(classLoader, name);
+ className = getServiceName(runtimeClassLoader, name);
}
if (className == null) {
- return new DefaultSCADomain(domainURI, contributionLocation, composites);
+ return new DefaultSCADomain(runtimeClassLoader, applicationClassLoader,
+ domainURI, contributionLocation, composites);
}
- Class cls = Class.forName(className, true, classLoader);
+ Class cls = Class.forName(className, true, runtimeClassLoader);
Constructor<?> constructor = cls.getConstructor(String.class, String.class, String[].class);
- SCADomain domain = (SCADomain)constructor.newInstance(domainURI, contributionLocation, composites);
+ SCADomain domain = (SCADomain)constructor.newInstance(
+ runtimeClassLoader, applicationClassLoader,
+ domainURI, contributionLocation, composites);
return domain;
} catch (Exception e) {
Added: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SCADomainBean.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SCADomainBean.java?view=auto&rev=535701
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SCADomainBean.java (added)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SCADomainBean.java Sun May 6 18:02:07 2007
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.tuscany.host.embedded;
+
+import org.osoa.sca.CallableReference;
+import org.osoa.sca.ServiceReference;
+
+public class SCADomainBean extends SCADomain {
+
+ private SCADomain instance;
+
+ private String uri = "http://localhost";
+ private String location = ".";
+ private String[] composites;
+
+ /**
+ * Constructs a new SCA domain
+ */
+ public SCADomainBean() {
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public void setContributionLocation(String contributionLocation) {
+ this.location = contributionLocation;
+ }
+
+ public String getContributionLocation() {
+ return location;
+ }
+
+ public void setDeployableComposites(String... composites) {
+ this.composites = composites;
+ }
+
+ public String[] getDeployableComposites() {
+ return composites;
+ }
+
+ @Override
+ public <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException {
+ if (instance == null) {
+ instance = SCADomain.createNewInstance(uri, location, composites);
+ }
+ return instance.cast(target);
+ }
+
+ @Override
+ public void close() {
+ if (instance == null) {
+ instance = SCADomain.createNewInstance(uri, location, composites);
+ }
+ instance.close();
+ }
+
+ @Override
+ public <B> B getService(Class<B> businessInterface, String serviceName) {
+ if (instance == null) {
+ instance = SCADomain.createNewInstance(uri, location, composites);
+ }
+ return instance.getService(businessInterface, serviceName);
+ }
+
+ @Override
+ public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String referenceName) {
+ if (instance == null) {
+ instance = SCADomain.createNewInstance(uri, location, composites);
+ }
+ return instance.getServiceReference(businessInterface, referenceName);
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SCADomainBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SCADomainBean.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/DefaultSCADomain.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/DefaultSCADomain.java?view=diff&rev=535701&r1=535700&r2=535701
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/DefaultSCADomain.java (original)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/DefaultSCADomain.java Sun May 6 18:02:07 2007
@@ -58,7 +58,7 @@
*/
public class DefaultSCADomain extends SCADomain {
- private String domainURI;
+ private String uri;
private String location;
private String[] composites;
private Composite domainComposite;
@@ -73,14 +73,14 @@
* @param contributionLocation
* @param composites
*/
- public DefaultSCADomain(String domainURI, String contributionLocation, String... composites) {
- this.domainURI = domainURI;
+ public DefaultSCADomain(ClassLoader runtimeClassLoader, ClassLoader applicationClassLoader,
+ String domainURI, String contributionLocation, String... composites) {
+ this.uri = domainURI;
this.location = contributionLocation;
this.composites = composites;
-
- ClassLoader runtimeClassLoader = getClass().getClassLoader();
+
+ // Create and start the runtime
runtime = new ReallySmallRuntime(runtimeClassLoader);
-
try {
runtime.start();
@@ -89,7 +89,6 @@
}
// Contribute the given contribution to an in-memory repository
- ClassLoader applicationClassLoader = Thread.currentThread().getContextClassLoader();
ContributionService contributionService = runtime.getContributionService();
URL contributionURL;
try {
@@ -303,7 +302,7 @@
@Override
public String getURI() {
- return domainURI;
+ return uri;
}
}
Added: incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/SCADomainBeanTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/SCADomainBeanTestCase.java?view=auto&rev=535701
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/SCADomainBeanTestCase.java (added)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/SCADomainBeanTestCase.java Sun May 6 18:02:07 2007
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.tuscany.host.embedded;
+
+import junit.framework.TestCase;
+
+import org.osoa.sca.ServiceReference;
+
+import crud.CRUD;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SCADomainBeanTestCase extends TestCase {
+
+ private SCADomainBean domain;
+
+ protected void setUp() throws Exception {
+ domain = new SCADomainBean();
+ domain.setDeployableComposites("crud.composite");
+ }
+
+ public void testStart() throws Exception {
+ ServiceReference<CRUD> serviceReference = domain.getServiceReference(CRUD.class, "CRUDServiceComponent");
+ assertNotNull(serviceReference);
+ CRUD service = serviceReference.getService();
+ String id = service.create("ABC");
+ Object result = service.retrieve(id);
+ assertEquals("ABC", result);
+ service.update(id, "EFG");
+ result = service.retrieve(id);
+ assertEquals("EFG", result);
+ service.delete(id);
+ result = service.retrieve(id);
+ assertNull(result);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ protected void tearDown() throws Exception {
+ domain.close();
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/SCADomainBeanTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/SCADomainBeanTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/SCADomainTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/SCADomainTestCase.java?view=auto&rev=535701
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/SCADomainTestCase.java (added)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/SCADomainTestCase.java Sun May 6 18:02:07 2007
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.tuscany.host.embedded;
+
+import junit.framework.TestCase;
+
+import org.osoa.sca.ServiceReference;
+
+import crud.CRUD;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SCADomainTestCase extends TestCase {
+
+ private SCADomain domain;
+
+ protected void setUp() throws Exception {
+ domain = SCADomain.newInstance("crud.composite");
+ }
+
+ public void testStart() throws Exception {
+ ServiceReference<CRUD> serviceReference = domain.getServiceReference(CRUD.class, "CRUDServiceComponent");
+ assertNotNull(serviceReference);
+ CRUD service = serviceReference.getService();
+ String id = service.create("ABC");
+ Object result = service.retrieve(id);
+ assertEquals("ABC", result);
+ service.update(id, "EFG");
+ result = service.retrieve(id);
+ assertEquals("EFG", result);
+ service.delete(id);
+ result = service.retrieve(id);
+ assertNull(result);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ protected void tearDown() throws Exception {
+ domain.close();
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/SCADomainTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/SCADomainTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/impl/DefaultSCADomainTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/impl/DefaultSCADomainTestCase.java?view=auto&rev=535701
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/impl/DefaultSCADomainTestCase.java (added)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/impl/DefaultSCADomainTestCase.java Sun May 6 18:02:07 2007
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.tuscany.host.embedded.impl;
+
+import junit.framework.TestCase;
+import crud.CRUD;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class DefaultSCADomainTestCase extends TestCase {
+ private DefaultSCADomain domain;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ protected void setUp() throws Exception {
+ domain = new DefaultSCADomain(getClass().getClassLoader(), getClass().getClassLoader(),
+ "http://localhost", ".", "crud.composite");
+ }
+
+ public void testStart() throws Exception {
+ CRUD service = domain.getService(CRUD.class, "CRUDServiceComponent");
+ assertNotNull(service);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ protected void tearDown() throws Exception {
+ domain.close();
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/impl/DefaultSCADomainTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/impl/DefaultSCADomainTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/samples/helloworld-wsclient/src/test/java/helloworld/HelloWorldClientTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/helloworld-wsclient/src/test/java/helloworld/HelloWorldClientTestCase.java?view=diff&rev=535701&r1=535700&r2=535701
==============================================================================
--- incubator/tuscany/java/sca/samples/helloworld-wsclient/src/test/java/helloworld/HelloWorldClientTestCase.java (original)
+++ incubator/tuscany/java/sca/samples/helloworld-wsclient/src/test/java/helloworld/HelloWorldClientTestCase.java Sun May 6 18:02:07 2007
@@ -21,13 +21,11 @@
import junit.framework.Assert;
-import org.apache.tuscany.host.embedded.SCARuntime;
+import org.apache.tuscany.host.embedded.SCADomain;
import org.apache.tuscany.host.embedded.SCATestCaseRunner;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.osoa.sca.ComponentContext;
-import org.osoa.sca.ServiceReference;
/**
* Test case for helloworld web service client
@@ -35,17 +33,15 @@
public class HelloWorldClientTestCase {
private HelloWorldService helloWorldService;
+ private SCADomain domain;
private SCATestCaseRunner server;
@Before
public void startClient() throws Exception {
try {
- SCARuntime.start("helloworldwsclient.composite");
-
- ComponentContext context = SCARuntime.getComponentContext("HelloWorldServiceComponent");
- ServiceReference<HelloWorldService> service = context.createSelfReference(HelloWorldService.class);
- helloWorldService = service.getService();
+ domain = SCADomain.newInstance("helloworldwsclient.composite");
+ helloWorldService = domain.getService(HelloWorldService.class, "HelloWorldServiceComponent");
server = new SCATestCaseRunner(HelloWorldServerTest.class);
server.before();
@@ -64,7 +60,7 @@
@After
public void stopClient() throws Exception {
server.after();
- SCARuntime.stop();
+ domain.close();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org