Examples of ComponentDescription


Examples of org.apache.felix.scrplugin.description.ComponentDescription

            this.createComponent(cad, describedClass, scannedClass);
        }

        // search for the component descriptions and use the first one
        final List<ComponentDescription> componentDescs = describedClass.getDescriptions(ComponentDescription.class);
        ComponentDescription found = null;
        if (!componentDescs.isEmpty()) {
            found = componentDescs.get(0);
        }

        if (found != null) {
            final ComponentDescription cd = found;

            // search for methods
            final List<MethodAnnotation> methodTags = scannedClass.getMethodAnnotations(null);
            for (final MethodAnnotation m : methodTags) {
                if (m.getName().equals(Activate.class.getName())) {
                    cd.setActivate(m.getAnnotatedMethod().getName());
                    scannedClass.processed(m);
                } else if (m.getName().equals(Deactivate.class.getName())) {
                    cd.setDeactivate(m.getAnnotatedMethod().getName());
                    scannedClass.processed(m);
                } else if (m.getName().equals(Modified.class.getName())) {
                    cd.setModified(m.getAnnotatedMethod().getName());
                    scannedClass.processed(m);
                } else if (m.getName().equals(Reference.class.getName()) ) {
                    this.processReference(describedClass, m);
                    scannedClass.processed(m);
                }
View Full Code Here

Examples of org.apache.felix.scrplugin.description.ComponentDescription

     */
    private ComponentDescription createComponent(final ClassAnnotation cad,
                    final ClassDescription describedClass,
                    final ScannedClass scannedClass)
    throws SCRDescriptorException {
        final ComponentDescription component = new ComponentDescription(cad);
        describedClass.add(component);

        // Although not defined in the spec, we support abstract classes.
        final boolean classIsAbstract = Modifier.isAbstract(scannedClass.getClass().getModifiers());
        component.setAbstract(classIsAbstract);

        // name
        component.setName(cad.getStringValue("name", scannedClass.getScannedClass().getName()));

        // services
        final List<String> listedInterfaces = new ArrayList<String>();
        if (cad.hasValue("service") ) {
            final String[] interfaces = (String[]) cad.getValue("service");
            if ( interfaces != null ) {
                for (final String t : interfaces) {
                    listedInterfaces.add(t);
                }
            }
        } else {
            // scan directly implemented interfaces
            this.searchInterfaces(listedInterfaces, scannedClass.getScannedClass());
        }
        if ( listedInterfaces.size() > 0 ) {
            final ServiceDescription serviceDesc = new ServiceDescription(cad);
            describedClass.add(serviceDesc);

            for(final String name : listedInterfaces) {
                serviceDesc.addInterface(name);
            }
            serviceDesc.setServiceFactory(cad.getBooleanValue("servicefactory", false));
        }

        // factory
        component.setFactory(cad.getStringValue("factory", null));

        // enabled
        if (cad.getValue("enabled") != null) {
            component.setEnabled(cad.getBooleanValue("enabled", true));
        }

        // immediate
        if (cad.getValue("immediate") != null) {
            component.setImmediate(cad.getBooleanValue("immediate", false));
        }

        // property
        final String[] property = (String[])cad.getValue("property");
        if ( property != null ) {
            // TODO - what do we do if the value is invalid?
            for(final String propDef : property) {
                final int pos = propDef.indexOf('=');
                if ( pos != -1 ) {
                    final String prefix = propDef.substring(0, pos);
                    final String value = propDef.substring(pos + 1);
                    final int typeSep = prefix.indexOf(':');
                    final String key = (typeSep == -1 ? prefix : prefix.substring(0, typeSep));
                    final String type = (typeSep == -1 ? PropertyType.String.name() : prefix.substring(typeSep + 1));

                    final PropertyType propType = PropertyType.valueOf(type);
                    // FELIX-4159 : check if this is a multi value prop
                    final List<PropertyDescription> existingProps = describedClass.getDescriptions(PropertyDescription.class);
                    PropertyDescription found = null;
                    for(final PropertyDescription current : existingProps) {
                        if ( current.getName().equals(key) ) {
                            found = current;
                            break;
                        }
                    }
                    if ( found == null ) {
                        final PropertyDescription pd = new PropertyDescription(cad);
                        describedClass.add(pd);
                        pd.setName(key);
                        pd.setValue(value);
                        pd.setType(propType);
                        pd.setUnbounded(PropertyUnbounded.DEFAULT);
                    } else {
                        if ( propType != found.getType() ) {
                            throw new SCRDescriptorException("Multi value property '" + key + "' has different types: "
                                    + found.getType() + " & " + propType,
                                    describedClass.getSource());
                        }
                        if ( found.getValue() != null ) {
                            final String[] values = new String[2];
                            values[0] = found.getValue();
                            values[1] = value;
                            found.setMultiValue(values);
                        } else {
                            final String[] oldValues = found.getMultiValue();
                            final String[] newValues = new String[oldValues.length + 1];
                            System.arraycopy(oldValues, 0, newValues, 0, oldValues.length);
                            newValues[oldValues.length] = value;
                            found.setMultiValue(newValues);
                        }
                    }
                }
            }
        }
        // TODO: properties

        // xmlns
        if (cad.getValue("xmlns") != null) {
            final SpecVersion spec = SpecVersion.fromNamespaceUrl(cad.getValue("xmlns").toString());
            if ( spec == null ) {
                throw new SCRDescriptorException("Unknown xmlns attribute value: " + cad.getValue("xmlns"),
                                describedClass.getSource());
            }
            component.setSpecVersion(spec);
        }

        // configuration policy
        component.setConfigurationPolicy(ComponentConfigurationPolicy.valueOf(cad.getEnumValue("configurationPolicy",
                        ComponentConfigurationPolicy.OPTIONAL.name())));

        // configuration pid
        component.setConfigurationPid(cad.getStringValue("configurationPid", null));
        component.setCreatePid(false);

        // no inheritance
        component.setInherit(false);

        return component;
    }
View Full Code Here

Examples of org.eclipse.wb.internal.core.model.description.ComponentDescription

  //
  // Constructor
  //
  ////////////////////////////////////////////////////////////////////////////
  public DefaultLayoutInfo(AstEditor editor, CreationSupport creationSupport) throws Exception {
    super(editor, new ComponentDescription(null), creationSupport);
    ObjectInfoUtils.setNewId(this);
    getDescription().setToolkit(ToolkitProvider.DESCRIPTION);
  }
View Full Code Here

Examples of org.eclipse.wb.internal.core.model.description.ComponentDescription

    List<LayoutDescription> descriptions =
        LayoutDescriptionHelper.get(GwtExtToolkitDescription.INSTANCE);
    for (final LayoutDescription description : descriptions) {
      final Class<?> layoutClass = editorLoader.loadClass(description.getLayoutClassName());
      final String creationId = description.getCreationId();
      ComponentDescription layoutComponentDescription =
          ComponentDescriptionHelper.getDescription(editor, layoutClass);
      ObjectInfoAction action = new ObjectInfoAction(this) {
        @Override
        protected void runEx() throws Exception {
          description.ensureLibraries(editor.getJavaProject());
          LayoutInfo layout =
              (LayoutInfo) JavaInfoUtils.createJavaInfo(
                  getEditor(),
                  layoutClass,
                  new ConstructorCreationSupport(creationId, true));
          setLayout(layout);
        }
      };
      action.setText(description.getName());
      action.setImageDescriptor(new ImageImageDescriptor(layoutComponentDescription.getIcon()));
      layoutsManager.add(action);
    }
  }
View Full Code Here

Examples of org.eclipse.wb.internal.core.model.description.ComponentDescription

    List<LayoutDescription> descriptions =
        LayoutDescriptionHelper.get(ExtGwtToolkitDescription.INSTANCE);
    for (final LayoutDescription description : descriptions) {
      final Class<?> layoutClass = editorLoader.loadClass(description.getLayoutClassName());
      final String creationId = description.getCreationId();
      ComponentDescription layoutComponentDescription =
          ComponentDescriptionHelper.getDescription(editor, layoutClass);
      ObjectInfoAction action = new ObjectInfoAction(this) {
        @Override
        protected void runEx() throws Exception {
          description.ensureLibraries(editor.getJavaProject());
          LayoutInfo layout =
              (LayoutInfo) JavaInfoUtils.createJavaInfo(
                  getEditor(),
                  layoutClass,
                  new ConstructorCreationSupport(creationId, true));
          setLayout(layout);
        }
      };
      action.setText(description.getName());
      action.setImageDescriptor(new ImageImageDescriptor(layoutComponentDescription.getIcon()));
      layoutsManager.add(action);
    }
  }
View Full Code Here

Examples of org.eclipse.wb.internal.core.model.description.ComponentDescription

  }

  private List<EventDescription> getEventDescriptions(ComponentInfo component) {
    List<EventDescription> descriptions = Lists.newArrayList();
    // fill
    ComponentDescription componentDescription = component.getDescription();
    Class<?> componentClass = componentDescription.getComponentClass();
    while (componentClass != null) {
      String paramaterName = "GXT.untyped.events: " + componentClass.getName();
      String parameter = JavaInfoUtils.getParameter(component, paramaterName);
      if (parameter != null) {
        String[] lines = StringUtils.split(parameter, "\n");
View Full Code Here

Examples of org.eclipse.wb.internal.core.xml.model.description.ComponentDescription

  //
  ////////////////////////////////////////////////////////////////////////////
  private final Map<String, ComponentDescription> m_gridElementDescriptions = Maps.newTreeMap();

  private ComponentDescription getElementDescription(String name) throws Exception {
    ComponentDescription description = m_gridElementDescriptions.get(name);
    if (description == null) {
      description = new ComponentDescription(Object.class);
      description.setToolkit(GwtToolkitDescription.INSTANCE);
      description.setIcon(ComponentDescriptionHelper.getIcon(
          getContext(),
          getDescription().getComponentClass(),
          "_" + name));
      m_gridElementDescriptions.put(name, description);
    }
View Full Code Here

Examples of org.jboss.as.ee.component.ComponentDescription

            final String beanClassName = classInfo.name().toString();

            // Get the managed bean name from the annotation
            final AnnotationValue nameValue = instance.value();
            final String beanName = nameValue == null || nameValue.asString().isEmpty() ? beanClassName : nameValue.asString();
            final ComponentDescription componentDescription = new ComponentDescription(beanName, beanClassName, moduleDescription, deploymentUnit.getServiceName());

            // Add the view
            ViewDescription viewDescription = new ViewDescription(componentDescription, beanClassName);
            viewDescription.getConfigurators().addFirst(new ViewConfigurator() {
                public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException {
                    // Add MB association interceptors
                    final Object contextKey = new Object();
                    configuration.addClientPostConstructInterceptor(new ManagedBeanCreateInterceptorFactory(contextKey), InterceptorOrder.ClientPostConstruct.INSTANCE_CREATE);
                    final ManagedBeanAssociatingInterceptorFactory associatingInterceptorFactory = new ManagedBeanAssociatingInterceptorFactory(contextKey);
                    configuration.addClientInterceptor(associatingInterceptorFactory, InterceptorOrder.Client.ASSOCIATING_INTERCEPTOR);
                    configuration.addClientPreDestroyInterceptor(new ManagedBeanDestroyInterceptorFactory(contextKey), InterceptorOrder.ClientPreDestroy.INSTANCE_DESTROY);
                    configuration.addViewInterceptor(new ImmediateInterceptorFactory(new TCCLInterceptor(componentConfiguration.getModuleClassLoader())), InterceptorOrder.View.TCCL_INTERCEPTOR);
                }
            });
            viewDescription.getBindingNames().addAll(Arrays.asList("java:module/" + beanName, "java:app/" + moduleDescription.getModuleName() + "/" + beanName));
            componentDescription.getViews().add(viewDescription);
            moduleDescription.addComponent(componentDescription);

            // register a EEResourceReferenceProcessor which can process @Resource references to this managed bean.
            registry.registerResourceReferenceProcessor(new ManagedBeanResourceReferenceProcessor(beanClassName));
        }
View Full Code Here

Examples of org.jboss.as.ee.component.ComponentDescription

            for (final EJBEndpoint ejbEndpoint : getJaxwsEjbs(unit)) {
                if (endpointClassName.equals(ejbEndpoint.getClassName())) {
                    for (final String handlerClassName : mapping.getHandlers(endpointClassName)) {
                        final String ejbEndpointName = ejbEndpoint.getName();
                        final String handlerName = ejbEndpointName + "-" + handlerClassName;
                        final ComponentDescription jaxwsHandlerDescription = createComponentDescription(unit, handlerName, handlerClassName, ejbEndpointName);
                        propagateNamingContext(jaxwsHandlerDescription, ejbEndpoint);
                    }
                }
            }
        } else {
View Full Code Here

Examples of org.jboss.as.ee.component.ComponentDescription

        return true;
    }

    static ComponentDescription createComponentDescription(final DeploymentUnit unit, final String componentName, final String componentClassName, final String dependsOnEndpointClassName) {
        final EEModuleDescription moduleDescription = getRequiredAttachment(unit, EE_MODULE_DESCRIPTION);
        ComponentDescription componentDescription = moduleDescription.getComponentByName(componentName);

        if (componentDescription == null) {
            // register WS component
            componentDescription = new WSComponentDescription(componentName, componentClassName, moduleDescription, unit.getServiceName());
            moduleDescription.addComponent(componentDescription);
            // register WS dependency
            final ServiceName endpointServiceName = EndpointService.getServiceName(unit, dependsOnEndpointClassName);
            componentDescription.addDependency(endpointServiceName, ServiceBuilder.DependencyType.REQUIRED);
        }

        return componentDescription;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.