    001// Copyright 2012-2013 The Apache Software Foundation
    002//
    003// Licensed under the Apache License, Version 2.0 (the "License");
    004// you may not use this file except in compliance with the License.
    005// You may obtain a copy of the License at
    006//
    007// http://www.apache.org/licenses/LICENSE-2.0
    008//
    009// Unless required by applicable law or agreed to in writing, software
    010// distributed under the License is distributed on an "AS IS" BASIS,
    011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    012// See the License for the specific language governing permissions and
    013// limitations under the License.
    014
    015package org.apache.tapestry5.clojure.modules;
    016
    017import clojure.lang.RT;
    018import clojure.lang.Var;
    019import org.apache.tapestry5.clojure.ClojureBuilder;
    020import org.apache.tapestry5.clojure.MethodToFunctionSymbolMapper;
    021import org.apache.tapestry5.internal.clojure.AnnotationMapper;
    022import org.apache.tapestry5.internal.clojure.ClojureBuilderImpl;
    023import org.apache.tapestry5.internal.clojure.DefaultMapper;
    024import org.apache.tapestry5.ioc.OrderedConfiguration;
    025import org.apache.tapestry5.ioc.ServiceBinder;
    026import org.apache.tapestry5.ioc.annotations.Contribute;
    027import org.apache.tapestry5.ioc.annotations.Startup;
    028import org.apache.tapestry5.ioc.services.ChainBuilder;
    029
    030import java.util.List;
    031
    032public class ClojureModule
    033{
    034    public static void bind(ServiceBinder binder)
    035    {
    036        binder.bind(ClojureBuilder.class, ClojureBuilderImpl.class);
    037    }
    038
    039    public static MethodToFunctionSymbolMapper buildMethodToFunctionMapper(List<MethodToFunctionSymbolMapper> configuration, ChainBuilder builder)
    040    {
    041        return builder.build(MethodToFunctionSymbolMapper.class, configuration);
    042    }
    043
    044    @Contribute(MethodToFunctionSymbolMapper.class)
    045    public static void defaultMappers(OrderedConfiguration<MethodToFunctionSymbolMapper> configuration)
    046    {
    047        configuration.add("Annotation", new AnnotationMapper());
    048        configuration.add("Default", new DefaultMapper(), "after:*");
    049    }
    050
    051    @Startup
    052    public static void launchClojure() {
    053        Var require = RT.var("clojure.core", "require");
    054    }
    055}