Package org.apache.tapestry5.plastic

Examples of org.apache.tapestry5.plastic.PlasticField


    public TransformField createField(int modifiers, String type, String suggestedName)
    {
        // TODO: modifiers are ignored

        PlasticField newField = plasticClass.introduceField(type, suggestedName);

        return toTransformField(newField);
    }
View Full Code Here


    public String addInjectedField(Class type, String suggestedName, Object value)
    {
        // TODO: The injected field is not actually protected or shared

        PlasticField field = plasticClass.introduceField(type, suggestedName).inject(value);

        return field.getName();
    }
View Full Code Here

    public <T> TransformField addIndirectInjectedField(Class<T> type, String suggestedName,
            ComponentValueProvider<T> provider)
    {

        PlasticField field = plasticClass.introduceField(type, suggestedName).injectComputed(toComputedValue(provider));

        return toTransformField(field);
    }
View Full Code Here

         * was introduced through this instance of BridgeClassTransformation.
         */
        public void replaceAccess(TransformField conduitField)
        {
            // Ugly:
            PlasticField conduitFieldPlastic = ((BridgeTransformField) conduitField).plasticField;

            final FieldHandle conduitHandle = conduitFieldPlastic.getHandle();

            plasticField.setConduit(new WrapFieldHandleForFieldValueConduitAsFieldConduit(conduitHandle));
        }
View Full Code Here

        {
            public void transform(final PlasticClass plasticClass)
            {
                plasticClass.introduceInterface(Serializable.class);

                final PlasticField creatorField = plasticClass.introduceField(ObjectCreator.class, "creator").inject(
                        creator);

                final PlasticField tokenField = plasticClass.introduceField(ServiceProxyToken.class, "token").inject(
                        token);

                PlasticMethod delegateMethod = plasticClass.introducePrivateMethod(serviceInterface.getName(),
                        "delegate", null, null);

                // If not concerned with efficiency, this might be done with method advice instead.
                delegateMethod.changeImplementation(new InstructionBuilderCallback()
                {
                    public void doBuild(InstructionBuilder builder)
                    {
                        builder.loadThis().getField(plasticClass.getClassName(), creatorField.getName(),
                                ObjectCreator.class);
                        builder.invoke(ObjectCreator.class, Object.class, "createObject").checkcast(serviceInterface)
                                .returnResult();
                    }
                });

                for (Method m : serviceInterface.getMethods())
                {
                    plasticClass.introduceMethod(m).delegateTo(delegateMethod);
                }

                plasticClass.introduceMethod(WRITE_REPLACE).changeImplementation(new InstructionBuilderCallback()
                {
                    public void doBuild(InstructionBuilder builder)
                    {
                        builder.loadThis()
                                .getField(plasticClass.getClassName(), tokenField.getName(), ServiceProxyToken.class)
                                .returnResult();
                    }
                });

                plasticClass.addToString(description);
View Full Code Here

        ClassInstantiator<T> instantiator = createProxy(interfaceType, new PlasticClassTransformer()
        {
            public void transform(PlasticClass plasticClass)
            {
                final PlasticField objectCreatorField = plasticClass.introduceField(ObjectCreator.class, "creator")
                        .inject(creator);

                PlasticMethod delegateMethod = plasticClass.introducePrivateMethod(interfaceType.getName(), "delegate",
                        null, null);
View Full Code Here

        Iterator<PlasticField> iterator = result.iterator();

        while (iterator.hasNext())
        {
            PlasticField plasticField = iterator.next();

            if (!plasticField.hasAnnotation(annotationType))
                iterator.remove();
        }

        return result;
    }
View Full Code Here

            verifyInitialState("set the computed FieldConduit for");

            // First step: define a field to store the conduit and add constructor logic
            // to initialize it

            PlasticField conduitField = introduceField(FieldConduit.class, node.name + "_FieldConduit").injectComputed(
                    computedConduit);

            replaceFieldReadAccess(conduitField.getName());
            replaceFieldWriteAccess(conduitField.getName());

            // TODO: Do we keep the field or not? It will now always be null/0/false.

            state = FieldState.CONDUIT;
View Full Code Here

            plasticClass.addToString(String.format("PropertyConduit[%s %s]", rootType.getName(), expression));
        }

        private void implementOtherMethods()
        {
            PlasticField annotationProviderField = plasticClass.introduceField(AnnotationProvider.class,
                    "annotationProvider").inject(annotationProvider);

            plasticClass.introduceMethod(ConduitMethods.GET_ANNOTATION).delegateTo(annotationProviderField);

            plasticClass.introduceMethod(ConduitMethods.GET_PROPERTY_NAME, new InstructionBuilderCallback()
            {
                public void doBuild(InstructionBuilder builder)
                {
                    builder.loadConstant(conduitPropertyName).returnResult();
                }
            });

            final PlasticField propertyTypeField = plasticClass.introduceField(Class.class, "propertyType").inject(
                    conduitPropertyType);

            plasticClass.introduceMethod(ConduitMethods.GET_PROPERTY_TYPE, new InstructionBuilderCallback()
            {
                public void doBuild(InstructionBuilder builder)
View Full Code Here

      PlasticMethod method, com.adaptivui.tapestry5.genetify.data.Goal goal, Worker<com.adaptivui.tapestry5.genetify.data.Goal> operation)
  {
    if (goal == null)
      return;

    PlasticField goalField = componentClass.introduceField(com.adaptivui.tapestry5.genetify.data.Goal.class,
        "goal_" + method.getDescription().methodName);

    initializeGoal(method, goal, goalField);

    addMethodGoalOperationAdvice(method, goalField.getHandle(), operation);
  }
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.plastic.PlasticField

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.