Package org.apache.tuscany.sca.implementation.osgi

Examples of org.apache.tuscany.sca.implementation.osgi.OSGiProperty


     */
    protected Hashtable<String, Object> getOSGiProperties(Extensible extensible) {
        Hashtable<String, Object> props = new Hashtable<String, Object>();
        for (Object ext : extensible.getExtensions()) {
            if (ext instanceof OSGiProperty) {
                OSGiProperty p = (OSGiProperty)ext;
                props.put(p.getName(), p.getValue());
            }
        }
        return props;
    }
View Full Code Here


        ComponentType componentType = (ComponentType)staxProcessor.read(reader);

        assertEquals(1, componentType.getServices().size());
        Object prop1 = componentType.getServices().get(0).getExtensions().get(0);
        assertTrue(prop1 instanceof OSGiProperty);
        OSGiProperty osgiProp1 = (OSGiProperty)prop1;
        assertEquals("1", osgiProp1.getValue());
        assertEquals("prop1", osgiProp1.getName());

        assertEquals(4, componentType.getReferences().size());
        Object prop2 = componentType.getReferences().get(0).getExtensions().get(1);
        assertTrue(prop2 instanceof OSGiProperty);
        OSGiProperty osgiProp2 = (OSGiProperty)prop2;
        assertEquals("ABC", osgiProp2.getValue());
        assertEquals("prop2", osgiProp2.getName());

        ModelResolver resolver = new TestModelResolver(getClass().getClassLoader());
        staxProcessor.resolve(componentType, resolver);
        resolver.addModel(componentType);
View Full Code Here

        ComponentType componentType = (ComponentType)staxProcessor.read(reader, context);

        assertEquals(1, componentType.getServices().size());
        Object prop1 = componentType.getServices().get(0).getExtensions().get(0);
        assertTrue(prop1 instanceof OSGiProperty);
        OSGiProperty osgiProp1 = (OSGiProperty)prop1;
        assertEquals("1", osgiProp1.getValue());
        assertEquals("prop1", osgiProp1.getName());

        assertEquals(4, componentType.getReferences().size());
        Object prop2 = componentType.getReferences().get(0).getExtensions().get(1);
        assertTrue(prop2 instanceof OSGiProperty);
        OSGiProperty osgiProp2 = (OSGiProperty)prop2;
        assertEquals("ABC", osgiProp2.getValue());
        assertEquals("prop2", osgiProp2.getName());

        ModelResolver resolver = new TestModelResolver(getClass().getClassLoader());
        staxProcessor.resolve(componentType, resolver, context);
        resolver.addModel(componentType, context);
View Full Code Here

            props.put(RemoteConstants.ENDPOINT_FRAMEWORK_UUID, uuid);
        }
       
        for (Object ext : endpoint.getService().getExtensions()) {
            if (ext instanceof OSGiProperty) {
                OSGiProperty prop = (OSGiProperty)ext;
                props.put(prop.getName(), prop.getStringValue());
            }
        }
       
        String serviceID = (String)props.get(Constants.SERVICE_ID);
        if (serviceID != null) {
View Full Code Here

     */
    protected Hashtable<String, Object> getOSGiProperties(Extensible extensible) {
        Hashtable<String, Object> props = new Hashtable<String, Object>();
        for (Object ext : extensible.getExtensions()) {
            if (ext instanceof OSGiProperty) {
                OSGiProperty p = (OSGiProperty)ext;
                props.put(p.getName(), p.getValue());
            }
        }
        return props;
    }
View Full Code Here

        this.factory = modelFactories.getFactory(OSGiImplementationFactory.class);
    }

    public OSGiProperty read(XMLStreamReader reader, ProcessorContext context) throws XMLStreamException {
        int event = reader.getEventType();
        OSGiProperty prop = null;
        while (true) {
            switch (event) {
                case START_ELEMENT:
                    QName name = reader.getName();
                    if (PROPERTY_QNAME.equals(name)) {
View Full Code Here

    public OSGiProperty createOSGiProperty() {
        return new OSGiPropertyImpl();
    }

    public OSGiProperty createOSGiProperty(String propName, String propValue, String propType) {
        OSGiProperty prop = new OSGiPropertyImpl();
        if (propType == null) {
            propType = "String";
        }
        prop.setName(propName);
        prop.setStringValue(propValue);
        prop.setType(propType);

        Object value = propValue;
        if ("Integer".equals(propType)) {
            value = Integer.valueOf(propValue);
        } else if ("Long".equals(propType)) {
            value = Long.valueOf(propValue);
        } else if ("Float".equals(propType)) {
            value = Float.valueOf(propValue);
        } else if ("Double".equals(propType)) {
            value = Double.valueOf(propValue);
        } else if ("Short".equals(propType)) {
            value = Short.valueOf(propValue);
        } else if ("Character".equals(propType)) {
            value = propValue.charAt(0);
        } else if ("Byte".equals(propType)) {
            value = Byte.valueOf(propValue);
        } else if ("Boolean".equals(propType)) {
            value = Boolean.valueOf(propValue);
        } else if ("String+".equals(propType)) {
            value = propValue.split(" ");
        } else {
            // String
            value = propValue;
        }
        prop.setValue(value);
        return prop;
    }
View Full Code Here

        prop.setValue(value);
        return prop;
    }

    public OSGiProperty createOSGiProperty(String propName, Object value) {
        OSGiProperty prop = new OSGiPropertyImpl();
        prop.setName(propName);
        prop.setValue(value);

        if (value instanceof String[]) {
            StringBuffer sb = new StringBuffer();
            for (String s : (String[])value) {
                sb.append(s).append(' ');
            }
            if (sb.length() > 0) {
                sb.deleteCharAt(sb.length() - 1);
            }
            prop.setStringValue(sb.toString());
            prop.setType("String+");
        } else if (value != null) {
            prop.setStringValue(String.valueOf(value));
            prop.setType(value.getClass().getSimpleName());
        }
        return prop;
    }
View Full Code Here

   
    public Collection<OSGiProperty> createOSGiProperties(ServiceReference reference) {
        List<OSGiProperty> props = new ArrayList<OSGiProperty>();
        for(String key: reference.getPropertyKeys()) {
            Object value = reference.getProperty(key);
            OSGiProperty prop = createOSGiProperty(key, value);
            props.add(prop);
        }
        return props;
    }       
View Full Code Here

    }       

    public Collection<OSGiProperty> createOSGiProperties(Map<String, Object> properties) {
        List<OSGiProperty> props = new ArrayList<OSGiProperty>();
        for (Map.Entry<String, Object> e : properties.entrySet()) {
            OSGiProperty prop = createOSGiProperty(e.getKey(), e.getValue());
            props.add(prop);
        }
        return props;
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.implementation.osgi.OSGiProperty

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.