Return-Path: Delivered-To: apmail-incubator-aries-commits-archive@minotaur.apache.org Received: (qmail 97649 invoked from network); 30 Oct 2010 15:43:45 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 30 Oct 2010 15:43:45 -0000 Received: (qmail 6836 invoked by uid 500); 30 Oct 2010 15:43:44 -0000 Delivered-To: apmail-incubator-aries-commits-archive@incubator.apache.org Received: (qmail 6633 invoked by uid 500); 30 Oct 2010 15:43:44 -0000 Mailing-List: contact aries-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: aries-dev@incubator.apache.org Delivered-To: mailing list aries-commits@incubator.apache.org Received: (qmail 6112 invoked by uid 99); 30 Oct 2010 15:43:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 30 Oct 2010 15:43:43 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED,T_FILL_THIS_FORM_SHORT X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 30 Oct 2010 15:43:39 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 29A3F2388A1C; Sat, 30 Oct 2010 15:42:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1029102 [3/5] - in /incubator/aries/trunk/samples-sandbox/dgoat: ./ dgoat-api/ dgoat-api/src/ dgoat-api/src/main/ dgoat-api/src/main/java/ dgoat-api/src/main/java/org/ dgoat-api/src/main/java/org/apache/ dgoat-api/src/main/java/org/apache/... Date: Sat, 30 Oct 2010 15:42:41 -0000 To: aries-commits@incubator.apache.org From: zoe@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101030154243.29A3F2388A1C@eris.apache.org> Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-info-enhancer/src/main/java/org/apache/aries/samples/goat/enhancer/ModelInfoEnhancerService.java URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-info-enhancer/src/main/java/org/apache/aries/samples/goat/enhancer/ModelInfoEnhancerService.java?rev=1029102&view=auto ============================================================================== --- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-info-enhancer/src/main/java/org/apache/aries/samples/goat/enhancer/ModelInfoEnhancerService.java (added) +++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-info-enhancer/src/main/java/org/apache/aries/samples/goat/enhancer/ModelInfoEnhancerService.java Sat Oct 30 15:42:36 2010 @@ -0,0 +1,339 @@ +/** + * 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.aries.samples.goat.enhancer; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.aries.samples.goat.api.ComponentInfo; +import org.apache.aries.samples.goat.api.ComponentInfoProvider; +import org.apache.aries.samples.goat.api.ModelInfoService; +import org.apache.aries.samples.goat.api.RelationshipInfo; +import org.apache.aries.samples.goat.api.RelationshipInfoProvider; + +import org.apache.aries.samples.goat.info.ComponentInfoImpl; +import org.apache.aries.samples.goat.info.RelationshipInfoImpl; + +public class ModelInfoEnhancerService implements ModelInfoService, + ComponentInfoProvider, RelationshipInfoProvider, + ComponentInfoProvider.ComponentInfoListener, + RelationshipInfoProvider.RelationshipInfoListener { + + private static final String SERVICE_REGISTRATION = "Service registration"; + + private static final String SERVICE_USAGE = "Service usage"; + + // TODO where should we expose these shared strings? + private static final String SERVICE = "Service"; + + private ModelInfoService originalService; + + private final Map components = new HashMap(); + private final Map relationships = new HashMap(); + + private final List clisteners; + private final List rlisteners; + + public ModelInfoEnhancerService(ModelInfoService infoService) { + + clisteners = Collections + .synchronizedList(new ArrayList()); + rlisteners = Collections + .synchronizedList(new ArrayList()); + + this.originalService = infoService; + Collection originalComponents = originalService + .getComponentInfoProvider().getComponents(); + // We keep all the original components + for (ComponentInfo info : originalComponents) { + components.put(info.getId(), info); + } + // We add a new component for each service + Collection originalRelationships = originalService + .getRelationshipInfoProvider().getRelationships(); + // We keep all the original components + for (RelationshipInfo rel : originalRelationships) { + + if (SERVICE.equals(rel.getType())) { + ComponentInfoImpl serviceComponent = new ComponentInfoImpl(); + String id = constructServiceComponentId(rel); + serviceComponent.setId(id); + Map componentProperties = new HashMap(); + componentProperties.put("Name", rel.getName()); + serviceComponent.setComponentProperties(componentProperties); + + components.put(id, serviceComponent); + + // Make new relationships; + + RelationshipInfoImpl registration = new RelationshipInfoImpl(); + registration.setType(SERVICE_REGISTRATION); + registration.setName(rel.getName()); + registration.setProvidedBy(rel.getProvidedBy()); + registration.setRelationshipAspects(rel + .getRelationshipAspects()); + + ArrayList arrayList = new ArrayList(); + arrayList.add(serviceComponent); + registration.setConsumedBy(arrayList); + + relationships.put(constructId(registration), registration); + + RelationshipInfoImpl consumption = new RelationshipInfoImpl(); + consumption.setType(SERVICE_USAGE); + consumption.setName(rel.getName()); + consumption.setProvidedBy(serviceComponent); + consumption.setConsumedBy(rel.getConsumedBy()); + consumption + .setRelationshipAspects(rel.getRelationshipAspects()); + + relationships.put(constructId(consumption), consumption); + + } else { + // Pass non-service relationships through + relationships.put(constructId(rel), rel); + + } + + originalService.getComponentInfoProvider() + .registerComponentInfoListener(this); + originalService.getRelationshipInfoProvider() + .registerRelationshipInfoListener(this); + } + + } + + @Override + public String getName() { + return "Model Enhancer Service"; + } + + @Override + public ComponentInfoProvider getComponentInfoProvider() { + return this; + } + + @Override + public RelationshipInfoProvider getRelationshipInfoProvider() { + return this; + } + + @Override + public Collection getRelationships() { + return relationships.values(); + } + + @Override + public Collection getComponents() { + return components.values(); + } + + @Override + public ComponentInfo getComponentForId(String id) { + return components.get(id); + } + + @Override + public void registerRelationshipInfoListener( + RelationshipInfoListener listener) { + rlisteners.add(listener); + } + + @Override + public void registerComponentInfoListener(ComponentInfoListener listener) { + clisteners.add(listener); + } + + @Override + public void updateRelationship(RelationshipInfo r) { + if (SERVICE.equals(r.getType())) { + updateSyntheticServiceArtefactsAndNotifyListeners(r); + } else { + // Update our copy + relationships.put(constructId(r), r); + // This shouldn't affect us, but pass it on to our listeners + for (RelationshipInfoListener listener : rlisteners) { + listener.updateRelationship(r); + } + } + + } + + @Override + public void removeRelationship(RelationshipInfo r) { + + if (SERVICE.equals(r.getType())) { + removeSyntheticServiceArtefactsAndNotifyListeners(r); + } else { + // We don't want to track this relationship anymore + String id = constructId(r); + RelationshipInfo relationship = relationships.get(id); + relationships.remove(id); + if (relationship != null) { + // This shouldn't affect us, but pass it on to our listeners + for (RelationshipInfoListener listener : rlisteners) { + listener.removeRelationship(relationship); + } + } + } + + } + + @Override + public void updateComponent(ComponentInfo b) { + // Update our copy + components.put(b.getId(), b); + // This shouldn't affect us, but pass it on to our listeners + for (ComponentInfoListener listener : clisteners) { + listener.updateComponent(b); + } + + } + + @Override + public void removeComponent(ComponentInfo b) { + // This shouldn't affect us unless it has relationships pointing to it + // Cheerfully assume that gets handled upstream + + // We don't want to know about this component anymore + ComponentInfo component = components.remove(b); + if (component != null) {// This shouldn't affect us, but pass it on to + // our listeners + for (ComponentInfoListener listener : clisteners) { + listener.removeComponent(component); + } + } + + } + + private String constructServiceComponentId(RelationshipInfo rel) { + return "/syntheticenhancedservices/" + rel.getName() + "/" + + rel.getProvidedBy().getId(); + } + + private String constructId(RelationshipInfo b) { + return b.getType() + "/" + b.getName() + "/" + + b.getProvidedBy().getId(); + } + + private void removeSyntheticServiceArtefactsAndNotifyListeners( + RelationshipInfo r) { + // We need to remove our two relationships and the synthetic + // component + + String componentId = constructServiceComponentId(r); + + // Do the relationships first + // The registration has type "service registration", and the + // original provider and name + String registrationRelationshipId = SERVICE_REGISTRATION + "/" + + r.getName() + "/" + r.getProvidedBy().getId(); + RelationshipInfo registrationRelationship = relationships + .get(registrationRelationshipId); + + // The consumers have type "service usage", and the + // original name, and the new provided by + + String usageRelationshipId = SERVICE_USAGE + "/" + r.getName() + "/" + + componentId; + RelationshipInfo usageRelationship = relationships + .get(usageRelationshipId); + + relationships.remove(usageRelationshipId); + relationships.remove(registrationRelationshipId); + + // Tell our listeners about the relationships first + + for (RelationshipInfoListener listener : rlisteners) { + if (usageRelationship != null) { + listener.removeRelationship(usageRelationship); + } + if (registrationRelationship != null) { + listener.removeRelationship(registrationRelationship); + } + + } + + ComponentInfo component = components.remove(componentId); + if (component != null) { + // Tell our listeners their service component went away + for (ComponentInfoListener listener : clisteners) { + listener.removeComponent(component); + } + } + } + + private void updateSyntheticServiceArtefactsAndNotifyListeners( + RelationshipInfo r) { + // We need to update our two relationships and the synthetic + // component + // Hopefully the thing which changed won't prevent us + // from finding our relationship + + String componentId = constructServiceComponentId(r); + + // Do the relationships first + // The registration has type "service registration", and the + // original provider and name + String registrationRelationshipId = SERVICE_REGISTRATION + "/" + + r.getName() + "/" + r.getProvidedBy().getId(); + RelationshipInfoImpl registrationRelationship = (RelationshipInfoImpl) relationships + .get(registrationRelationshipId); + registrationRelationship.setName(r.getName()); + registrationRelationship.setRelationshipAspects(r + .getRelationshipAspects()); + + // The consumers have type "service usage", and the + // original name, and the new provided by + + String usageRelationshipId = SERVICE_USAGE + "/" + r.getName() + "/" + + componentId; + RelationshipInfoImpl usageRelationship = (RelationshipInfoImpl) relationships + .get(usageRelationshipId); + + // The consumers may have changed, so we update the usage relationship + usageRelationship.setConsumedBy(r.getConsumedBy()); + usageRelationship.setName(r.getName()); + usageRelationship.setRelationshipAspects(r.getRelationshipAspects()); + + // Tell our listeners about the relationships first + + for (RelationshipInfoListener listener : rlisteners) { + if (usageRelationship != null) { + listener.updateRelationship(usageRelationship); + } + if (registrationRelationship != null) { + listener.updateRelationship(registrationRelationship); + } + + } + + ComponentInfo component = components.get(componentId); + if (component != null) { + // Tell our listeners their service component was updated + for (ComponentInfoListener listener : clisteners) { + listener.updateComponent(component); + } + } + } +} Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-info-enhancer/src/main/java/org/apache/aries/samples/goat/enhancer/ServiceInterceptor.java URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-info-enhancer/src/main/java/org/apache/aries/samples/goat/enhancer/ServiceInterceptor.java?rev=1029102&view=auto ============================================================================== --- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-info-enhancer/src/main/java/org/apache/aries/samples/goat/enhancer/ServiceInterceptor.java (added) +++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-info-enhancer/src/main/java/org/apache/aries/samples/goat/enhancer/ServiceInterceptor.java Sat Oct 30 15:42:36 2010 @@ -0,0 +1,131 @@ +/** + * 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.aries.samples.goat.enhancer; + +import java.util.Dictionary; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Map; + +import org.apache.aries.samples.goat.api.ModelInfoService; +import org.osgi.framework.BundleContext; +import org.osgi.framework.InvalidSyntaxException; +import org.osgi.framework.ServiceEvent; +import org.osgi.framework.ServiceListener; +import org.osgi.framework.ServiceReference; +import org.osgi.framework.ServiceRegistration; + +public class ServiceInterceptor implements ServiceListener { + + private static final String DISPLAY_NAME = "displayName"; + /** + * + */ + public static final String SERVICE_ID = "service.id"; + private final BundleContext ctx; + private final Map registrations = new HashMap(); + + public ServiceInterceptor(BundleContext ctx) { + this.ctx = ctx; + // Check all the existing services + try { + // Handle any existing services + ServiceReference[] references = ctx.getAllServiceReferences( + ModelInfoService.class.getName(), null); + + + ctx.addServiceListener(this, "(objectclass='" + + ModelInfoService.class.getName() + "')"); + + //If we found any service references... + if(references != null && references.length != 0) { + for (ServiceReference reference : references) { + registerServiceEnhancer(reference); + } + } + + + } catch (InvalidSyntaxException e) { + e.printStackTrace(); + } + // We could listen for find events and mask the original services if we + // wanted to + // ServiceRegistration findRegistration = + // ctx.registerService(FindHook.class.getName(), + // new InterceptorFindHook(), null); + } + + /* + * (non-Javadoc) + * + * @see + * org.osgi.framework.ServiceListener#serviceChanged(org.osgi.framework. + * ServiceEvent) + */ + @Override + public void serviceChanged(ServiceEvent event) { + ServiceReference reference = event.getServiceReference(); + if (event != null && event.getType() == ServiceEvent.REGISTERED) { + registerServiceEnhancer(reference); + + } else if (event != null + && event.getType() == ServiceEvent.UNREGISTERING) { + // Better unregister our enhancer + Object id = reference.getProperty(SERVICE_ID); + ServiceRegistration registration = registrations.get(id); + if (registration != null) { + registration.unregister(); + registrations.remove(id); + } + } + + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + private void registerServiceEnhancer(ServiceReference reference) { + Object actualService = ctx.getService(reference); + + if (actualService instanceof ModelInfoService) { + ModelInfoService infoService = (ModelInfoService) actualService; + Object serviceId = reference.getProperty(SERVICE_ID); + Object enhancer = new ModelInfoEnhancerService(infoService); + Dictionary properties = new Hashtable(); + Object originalDisplayName = reference.getProperty(DISPLAY_NAME); + properties.put(DISPLAY_NAME, originalDisplayName + " [enhanced]"); + ServiceRegistration registration = ctx.registerService( + ModelInfoService.class.getName(), enhancer, properties); + registrations.put(serviceId + "", registration); + } else { + System.out.println("Oh dear - unexpected service " + + actualService.getClass()); + } + } + + /** + * + */ + public void stop() { + for (ServiceRegistration registration : registrations.values()) { + registration.unregister(); + } + + } + +} Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-info-enhancer/src/main/resources/OSGI-INF/cxf/intents/intent-map.xml URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-info-enhancer/src/main/resources/OSGI-INF/cxf/intents/intent-map.xml?rev=1029102&view=auto ============================================================================== --- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-info-enhancer/src/main/resources/OSGI-INF/cxf/intents/intent-map.xml (added) +++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-info-enhancer/src/main/resources/OSGI-INF/cxf/intents/intent-map.xml Sat Oct 30 15:42:36 2010 @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-info-enhancer/src/main/resources/OSGI-INF/remote-services.xml URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-info-enhancer/src/main/resources/OSGI-INF/remote-services.xml?rev=1029102&view=auto ============================================================================== --- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-info-enhancer/src/main/resources/OSGI-INF/remote-services.xml (added) +++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-info-enhancer/src/main/resources/OSGI-INF/remote-services.xml Sat Oct 30 15:42:36 2010 @@ -0,0 +1,14 @@ + + + + + org.apache.aries.samples.goat.api.ModelInfoService + + + + http://localhost:9090/bundlectx + org.apache.cxf.ws + + + + Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-server-bindings/pom.xml URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-server-bindings/pom.xml?rev=1029102&view=auto ============================================================================== --- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-server-bindings/pom.xml (added) +++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-server-bindings/pom.xml Sat Oct 30 15:42:36 2010 @@ -0,0 +1,47 @@ + + + + + 4.0.0 + + org.apache.aries.samples.dgoat + dgoat + 0.3-incubating-SNAPSHOT + + + org.apache.aries.samples.dgoat.serverBindings + Apache Aries GOAT SCA server bindings + bundle + + + + + org.apache.felix + maven-bundle-plugin + + + ${pom.artifactId} + OSGI-INF/sca-config/scaconfig.xml + + + + + + + + Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-server-bindings/src/main/resources/OSGI-INF/sca-config/scaconfig.xml URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-server-bindings/src/main/resources/OSGI-INF/sca-config/scaconfig.xml?rev=1029102&view=auto ============================================================================== --- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-server-bindings/src/main/resources/OSGI-INF/sca-config/scaconfig.xml (added) +++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-server-bindings/src/main/resources/OSGI-INF/sca-config/scaconfig.xml Sat Oct 30 15:42:36 2010 @@ -0,0 +1,8 @@ + + + + Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/pom.xml URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/pom.xml?rev=1029102&view=auto ============================================================================== --- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/pom.xml (added) +++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/pom.xml Sat Oct 30 15:42:36 2010 @@ -0,0 +1,149 @@ + + + + + 4.0.0 + + org.apache.aries.samples.dgoat + dgoat + 0.3-incubating-SNAPSHOT + + + org.apache.aries.samples.dgoat.web + Apache Aries GOAT web bundle + bundle + + + + + org.eclipse + osgi + + + org.apache.felix + javax.servlet + 1.0.0 + + + org.directwebremoting + dwr + 3.0.0.109.dev-SNAPSHOT + provided + true + + + org.apache.aries.application + org.apache.aries.application.utils + + + org.apache.aries.samples.dgoat + org.apache.aries.samples.dgoat.api + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack dojo + generate-sources + + unpack + + + + + org.dojotoolkit + dojo + 1.4.2 + zip + + + ${project.build.directory}/dojo + + + + + + org.apache.felix + maven-bundle-plugin + + + .,WEB-INF/lib + {maven-resources},target/dojo/dojo-1.4.2 + / + ${pom.artifactId} + org.apache.aries.samples.goat.web.* + + org.apache.aries.samples.goat.info, + javax.imageio, + javax.jms;resolution:=optional, + javax.servlet, + javax.servlet.http, + javax.sql, + javax.swing.event, + javax.xml.parsers, + javax.xml.transform, + javax.xml.transform.dom, + javax.xml.transform.stream, + org.w3c.dom, + org.xml.sax, + net.sf.hibernate;resolution:=optional, + nu.xom;resolution:=optional, + org.aopalliance.intercept;resolution:=optional, + org.apache.bsf;resolution:=optional, + org.apache.catalina;resolution:=optional, + org.apache.commons.fileupload;resolution:=optional, + org.apache.commons.fileupload.disk;resolution:=optional, + org.apache.commons.fileupload.servlet;resolution:=optional, + org.apache.commons.logging;resolution:=optional, + org.apache.struts.action;resolution:=optional, + org.apache.struts.config;resolution:=optional, + org.apache.struts.util;resolution:=optional, + org.apache.xmlbeans;resolution:=optional, + org.dom4j*;resolution:=optional, + org.hibernate*;resolution:=optional, + org.jdom*;resolution:=optional, + org.mortbay*;resolution:=optional, + org.mozilla*;resolution:=optional, + org.springframework*;resolution:=optional, + com.google.inject*;resolution:=optional, + com.yahoo.platform.yui.compressor;resolution:=optional, + dojox.cometd;resolution:=optional, + * + + dwr + WEB-INF/lib + + + + + + + + + dwr-snapshots + DWR SNAPSHOT Repository + http://download.directwebremoting.org/maven2-snapshot/ + + + Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/java/org/apache/aries/samples/goat/web/ServerSideClass.java URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/java/org/apache/aries/samples/goat/web/ServerSideClass.java?rev=1029102&view=auto ============================================================================== --- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/java/org/apache/aries/samples/goat/web/ServerSideClass.java (added) +++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/java/org/apache/aries/samples/goat/web/ServerSideClass.java Sat Oct 30 15:42:36 2010 @@ -0,0 +1,284 @@ +/** + * 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.aries.samples.goat.web; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import javax.servlet.ServletContext; + +import org.apache.aries.samples.goat.info.ComponentInfoImpl; +import org.apache.aries.samples.goat.info.RelationshipInfoImpl; + +import org.apache.aries.samples.goat.api.ComponentInfo; +import org.apache.aries.samples.goat.api.ComponentInfoProvider; +import org.apache.aries.samples.goat.api.ModelInfoService; +import org.apache.aries.samples.goat.api.RelationshipInfo; +import org.apache.aries.samples.goat.api.RelationshipInfoProvider; + +import org.directwebremoting.Browser; +import org.directwebremoting.ScriptBuffer; +import org.directwebremoting.ScriptSession; +import org.directwebremoting.ServerContextFactory; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.InvalidSyntaxException; +import org.osgi.framework.ServiceReference; + +public class ServerSideClass { + + private String modelInfoServiceHint = ""; + + private ModelInfoService ModelInfoService = null; + + private Map clisteners = new HashMap(); + private Map rlisteners = new HashMap(); + + private class ComponentInfoListenerImpl implements + ComponentInfoProvider.ComponentInfoListener { + String server; + + public ComponentInfoListenerImpl(String server) { + this.server = server; + } + + public void updateComponent(ComponentInfo b) { + if (this.server.equals(modelInfoServiceHint)) { + // todo: only issue the add for the new bundle, and affected + // other bundles. + //getInitialComponents(modelInfoServiceHint); + //System.out.println("State is: " + b.getComponentProperties().get("State")); + addFunctionCall("addComponent", b); + } + } + + public void removeComponent(ComponentInfo b) { + // todo + } + } + private class RelationshipInfoListenerImpl implements + RelationshipInfoProvider.RelationshipInfoListener { + String server; + + public RelationshipInfoListenerImpl(String server) { + this.server = server; + } + + public void updateRelationship(RelationshipInfo r) { + if (this.server.equals(modelInfoServiceHint)) { + addFunctionCall("addRelationship", r); + } + } + + public void removeRelationship(RelationshipInfo r) { + // todo + } + } + + public ServerSideClass() { + System.err.println("SSC Built!"); + + } + + @SuppressWarnings("unused") + private String bundleStateToString(int bundleState) { + switch (bundleState) { + case Bundle.UNINSTALLED: + return "UNINSTALLED"; + case Bundle.INSTALLED: + return "INSTALLED"; + case Bundle.RESOLVED: + return "RESOLVED"; + case Bundle.STARTING: + return "STARTING"; + case Bundle.STOPPING: + return "STOPPING"; + case Bundle.ACTIVE: + return "ACTIVE"; + default: + return "UNKNOWN[" + bundleState + "]"; + } + } + + /** + * this is invoked by a page onload.. so until it's invoked.. we dont care + * about components + */ + public void getInitialComponents(String dataProvider) { + + System.err.println("GET INITIAL BUNDLES ASKED TO USE DATAPROVIDER " + + dataProvider); + + if (dataProvider == null) + throw new IllegalArgumentException( + "Unable to accept 'null' as a dataProvider"); + + // do we need to update? + if (!this.modelInfoServiceHint.equals(dataProvider)) { + + this.modelInfoServiceHint = dataProvider; + + if (!(this.ModelInfoService == null)) { + // we already had a provider.. we need to shut down the existing + // components & relationships in the browsers.. + addFunctionCall("forgetAboutEverything"); + } + + ServletContext context = org.directwebremoting.ServerContextFactory + .get().getServletContext(); + Object o = context.getAttribute("osgi-bundlecontext"); + if (o != null) { + if (o instanceof BundleContext) { + BundleContext b_ctx = (BundleContext) o; + + System.err.println("Looking up bcip"); + try { + ServiceReference sr[] = b_ctx.getServiceReferences( + ModelInfoService.class.getName(), + "(displayName=" + this.modelInfoServiceHint + + ")"); + if (sr != null) { + System.err.println("Getting bcip"); + this.ModelInfoService = (ModelInfoService) b_ctx + .getService(sr[0]); + System.err.println("Got bcip " + + this.ModelInfoService); + } else { + System.err.println("UNABLE TO FIND BCIP!!"); + System.err.println("UNABLE TO FIND BCIP!!"); + System.err.println("UNABLE TO FIND BCIP!!"); + } + } catch (InvalidSyntaxException ise) { + + } + + if (this.ModelInfoService != null) { + if (!rlisteners.containsKey(this.ModelInfoService)) { + RelationshipInfoProvider.RelationshipInfoListener rl = new RelationshipInfoListenerImpl( + this.modelInfoServiceHint); + rlisteners.put(this.ModelInfoService, rl); + this.ModelInfoService.getRelationshipInfoProvider() + .registerRelationshipInfoListener(rl); + } + + if (!clisteners.containsKey(this.ModelInfoService)) { + ComponentInfoProvider.ComponentInfoListener cl = new ComponentInfoListenerImpl( + this.modelInfoServiceHint); + clisteners.put(this.ModelInfoService, cl); + this.ModelInfoService.getComponentInfoProvider() + .registerComponentInfoListener(cl); + } + } + } + } + + } + + Collection bis = this.ModelInfoService + .getComponentInfoProvider().getComponents(); + System.err.println("Got " + (bis == null ? "null" : bis.size()) + + " components back from the provider "); + if (bis != null) { + for (ComponentInfo b : bis) { + + System.err.println("Adding Component .. " + b.getId()); + + addFunctionCall("addComponent", b); + } + } + + Collection ris = this.ModelInfoService + .getRelationshipInfoProvider().getRelationships(); + System.err.println("Got " + (ris == null ? "null" : ris.size()) + + " relationships back from the provider "); + if (ris != null) { + for (RelationshipInfo r : ris) { + System.err.println("Adding relationship type " + r.getType() + + " called " + r.getName() + " from " + + r.getProvidedBy().getId()); + + addFunctionCall("addRelationship", r); + } + } + + } + + private void addFunctionCall(String name, Object... params) { + final ScriptBuffer script = new ScriptBuffer(); + script.appendScript(name).appendScript("("); + for (int i = 0; i < params.length; i++) { + if (i != 0) + script.appendScript(","); + script.appendData(params[i]); + } + script.appendScript(");"); + Browser.withAllSessions(new Runnable() { + public void run() { + for (ScriptSession s : Browser.getTargetSessions()) { + s.addScript(script); + } + } + }); + } + + public String[] getProviders() { + System.err.println("Getting providers..."); + ArrayList result = new ArrayList(); + ServletContext context = ServerContextFactory.get().getServletContext(); + Object o = context.getAttribute("osgi-bundlecontext"); + if (o != null) { + if (o instanceof BundleContext) { + BundleContext b_ctx = (BundleContext) o; + try { + System.err.println("Getting providers [2]..."); + ServiceReference[] srs = b_ctx.getServiceReferences( + ModelInfoService.class.getName(), null); + System.err.println("Got.. " + srs); + if (srs == null || srs.length == 0) { + System.err.println("NO DATA PROVIDERS"); + throw new RuntimeException( + "Unable to find any data providers"); + } + System.err.println("Processing srs as loop."); + for (ServiceReference sr : srs) { + System.err.println("Processing srs entry..."); + + String name = (String.valueOf(sr + .getProperty("displayName"))); + + result.add(name); + } + System.err.println("Processed srs as loop."); + } catch (InvalidSyntaxException e) { + // wont happen, the exception relates to the filter, (2nd + // arg above), which is constant null. + } + } + } + System.err.println("Returning " + result.size()); + String[] arr = new String[result.size()]; + arr = result.toArray(arr); + for (String x : arr) { + System.err.println(" - " + x); + } + return arr; + } +} Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/WEB-INF/dwr.xml URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/WEB-INF/dwr.xml?rev=1029102&view=auto ============================================================================== --- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/WEB-INF/dwr.xml (added) +++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/WEB-INF/dwr.xml Sat Oct 30 15:42:36 2010 @@ -0,0 +1,28 @@ + + + + + + + + + + + + + Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/WEB-INF/web.xml URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/WEB-INF/web.xml?rev=1029102&view=auto ============================================================================== --- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/WEB-INF/web.xml (added) +++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/WEB-INF/web.xml Sat Oct 30 15:42:36 2010 @@ -0,0 +1,50 @@ + + + + GOAT + + index.html + index.htm + index.jsp + default.html + default.htm + default.jsp + + + + dwr-invoker + org.directwebremoting.servlet.DwrServlet + + + debug + true + + + + activeReverseAjaxEnabled + true + + + + + + dwr-invoker + /dwr/* + + + Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/Thumbs.db URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/Thumbs.db?rev=1029102&view=auto ============================================================================== Binary file - no diff available. Propchange: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/Thumbs.db ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/dndCopy.png URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/dndCopy.png?rev=1029102&view=auto ============================================================================== Binary file - no diff available. Propchange: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/dndCopy.png ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/dndMove.png URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/dndMove.png?rev=1029102&view=auto ============================================================================== Binary file - no diff available. Propchange: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/dndMove.png ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/dndNoCopy.png URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/dndNoCopy.png?rev=1029102&view=auto ============================================================================== Binary file - no diff available. Propchange: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/dndNoCopy.png ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/dndNoMove.png URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/dndNoMove.png?rev=1029102&view=auto ============================================================================== Binary file - no diff available. Propchange: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/dndNoMove.png ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/grid_dx_gradient.gif URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/grid_dx_gradient.gif?rev=1029102&view=auto ============================================================================== Binary file - no diff available. Propchange: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/grid_dx_gradient.gif ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/grid_sort_down.gif URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/grid_sort_down.gif?rev=1029102&view=auto ============================================================================== Binary file - no diff available. Propchange: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/grid_sort_down.gif ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/grid_sort_up.gif URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/grid_sort_up.gif?rev=1029102&view=auto ============================================================================== Binary file - no diff available. Propchange: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/grid_sort_up.gif ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/header.png URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/header.png?rev=1029102&view=auto ============================================================================== Binary file - no diff available. Propchange: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/header.png ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/header_shadow.png URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/header_shadow.png?rev=1029102&view=auto ============================================================================== Binary file - no diff available. Propchange: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/header_shadow.png ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/resolved.png URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/resolved.png?rev=1029102&view=auto ============================================================================== Binary file - no diff available. Propchange: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/resolved.png ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/row_back.png URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/row_back.png?rev=1029102&view=auto ============================================================================== Binary file - no diff available. Propchange: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/row_back.png ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/running.png URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/running.png?rev=1029102&view=auto ============================================================================== Binary file - no diff available. Propchange: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/running.png ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/tabEnabled_rotated.png URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/tabEnabled_rotated.png?rev=1029102&view=auto ============================================================================== Binary file - no diff available. Propchange: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/tabEnabled_rotated.png ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/tabHover_rotated.png URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/tabHover_rotated.png?rev=1029102&view=auto ============================================================================== Binary file - no diff available. Propchange: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/tabHover_rotated.png ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/td_button_down.png URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/td_button_down.png?rev=1029102&view=auto ============================================================================== Binary file - no diff available. Propchange: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/images/td_button_down.png ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/Component.js URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/Component.js?rev=1029102&view=auto ============================================================================== --- incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/Component.js (added) +++ incubator/aries/trunk/samples-sandbox/dgoat/dgoat-web/src/main/resources/web/goat/Component.js Sat Oct 30 15:42:36 2010 @@ -0,0 +1,390 @@ +/** + * 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. + */ +dojo.provide("goat.Component"); +dojo.require("dojox.gfx"); +dojo.require("dojox.gfx.fx"); +dojo.require("dojox.gfx.Moveable"); + +dojo.require("goat.elements.ElementBase"); +dojo.require("goat.elements.ElementRegistry"); +dojo.require("goat.elements.ComponentContainer"); +dojo.require("goat.elements.TextComponentProperty"); +dojo.require("goat.RelationshipManager"); +dojo.require("goat.ElementLayoutManager"); + +dojo.require("goat.configuration.Theme"); +dojo.require("goat.configuration.ComponentAppearance"); + +// Component, +// looks after a component shape on the surface. +// +dojo.declare("goat.Component", [], { + + // fixed properties. + + /* String */id : null, // must be unique within enclosing component, if + // any, or globally if none. + /* goat.Component[] */children : null, + /* goat.elements.ElementBase[] */elements : null, // gui display elements + // within this component, + // all must extend + // 'goat.elements.ElementBase' + + // manager objects.. + /* goat.RelationshipManager */relationshipManager : null, // manager for + // handling all + // relationships + // to/from this + // component. + /* goat.ElementLayoutManager */elementLayoutManager : null, // manager for + // arranging + // elements + // within a + // component. + /* goat.elements.ElementRegistry */elementRegistry : null, // manager for + // returning + // appropriate + // renderers for + // component + // elements + + // state. + /* boolean */hidden : false, // is component visible on the surface. + /* boolean */selected : false, // is mouse currently within our boundary ? + /* boolean */refreshing : false, // is a refresh in progress ? + + // gfx objects + /* dojox.gfx.Group */group : null, + /* dojox.gfx.Surface */surface : null, + /* dojox.gfx.Rect */outline : null, + + /* goat.configuration.ComponentAppearance */componentAppearance : null, + // dimensions/coords - onsurface positioning. + /* int */x : 0, + /* int */y : 0, + /* int */width : null, + /* int */height : null, + + /* int */minWidth : 150, + /* int */minHeight : 80, + + constructor : function(/* dojox.gfx.Surface */surface, + /* String */id, + /* String[] */props, + /* goat.Component[] */children, /* goat.configuration */theme) { + + this.surface = surface; + this.x = 0; + this.y = 0; + this.height = 115; + this.width = this.minWidth; + + // TODO if we have a parent we should pass through their component + // appearance */ + this.componentAppearance = new goat.configuration.ComponentAppearance( + theme, null); + // console.log("Adding Box"); + this.initGfx(); + + this.id = id; + this.elements = new Array(); + + this.children = children; + if (this.children != null) { + var type = "component.container"; + var element = this.elementRegistry.getProperty(this.group, + this.componentAppearance, type, children); + this.elements[type] = element; + } + + this.elementRegistry = new goat.elements.ElementRegistry(this, props); + this.elementRegistry = this.elementRegistry.getRegistry(); + + this.updateProperties(props); + + // console.log("Creating RM"); + this.relationshipManager = new goat.RelationshipManager(this); + // console.log("Creating ELM"); + this.elementLayoutManager = new goat.ElementLayoutManager(this); + + // console.log("Invoking refresh"); + this.refresh(); + + var mover = new dojox.gfx.Moveable(this.group); + dojo.connect(mover, "onMoved", this, "onMoved"); + + this.group.connect("onclick", dojo.hitch(this, "onClick")); + this.group.connect("onmouseenter", dojo.hitch(this, "onMouseEnter")); + this.group.connect("onmouseleave", dojo.hitch(this, "onMouseLeave")); + + dojo.publish("goat.component.create", [ this ]); + + dojo.subscribe("goat.component.refresh", this, this.onRefresh); +}, +updateProperties : function(props) { + // console.log("Processing properties"); + // console.log(props); + + this.componentProperties = new Array(); + for ( var key in props) { + var value = props[key]; + // console.log("The fieldname or key is: "+key+" and the value at that + // field is: "+value); + var type = "component.property." + key; + if (this.elements[type] == null) { + var element = this.elementRegistry.getProperty(this, + this.componentAppearance, type, value); + this.elements[type] = element; + } else { + this.elements[type].update(value); + } + } + // TODO: what about elements in this.elements that were not present in + // props, + // should they be removed from the this.elements array.. currently elements + // dont + // support a 'remove' method. + // for now, as components dont need removing, wont worry about this. + + // console.log("Properties processed."); +}, +removeSelf : function() { + + //Remove this component and all the relationship elements attached to it. + this.surface.remove(this.group); + //Now we remove all other the elements + for (var type in this.elements) { + console.log("Removing element of type : " + type); + this.elements[type].removeSelf(); + delete this.elements[type]; + } + this.relationshipManager.removeSelf(); + delete this.RelationshipManager; + + //This one is subscribed to by Relationship + dojo.publish("goat.component.delete." + this.id, [ this ]); + + //This one is subscribed to by ComponentStatusGrid + dojo.publish("goat.component.delete", [ this ]); +}, +initGfx : function() { + this.group = this.surface.createGroup(); + + this.outline = this.group.createRect( { + x : 0, + y : 0, + width : this.width, + height : this.height, + r : 5 + }).setStroke( { + width : 2, + color : this.componentAppearance.getOutlineColor0() + }) + + if (this.componentAppearance.useLinearShading()) { + this.outline.setFill( { + type : "linear", + x1 : 0, + y1 : 0, + x2 : 150, + y2 : 80, + colors : [ { + offset : 0, + color : this.componentAppearance.getBackgroundColor() + }, { + offset : 1, + color : this.componentAppearance.getBackgroundContrastColor() + } ] + }); + } else { + this.outline.setFill(this.componentAppearance.getBackgroundColor()); + + } + +}, +refresh : function() { + // console.log(">Component.refresh"); + this.elementLayoutManager.doLayout(); + + // console.log("Sizing box"); + // not compatible with component shape property! + this.outline.setShape( { + x : 0, + y : 0, + width : this.width, + height : this.height, + r : 5 + }); + + if (this.componentAppearance.useLinearShading()) { + this.outline.setFill( { + type : "linear", + x1 : 0, + y1 : 0, + x2 : 150, + y2 : 80, + colors : [ { + offset : 0, + color : this.componentAppearance.getBackgroundColor() + }, { + offset : 1, + color : this.componentAppearance.getBackgroundContrastColor() + } ] + }); + } else { + this.outline.setFill(this.componentAppearance.getBackgroundColor()); + + } + // console.log("Movng to front"); + // make sure we can be seen. + this.group.moveToFront(); + // console.log("