S2Conteiner2.4ã®å®ç¾©æ¸ã¿ãªãã¸ã§ã¯ã
ããªãè¿è¦ç¼çã§ããããããæ¸ãã¦ã¿ã¾ãããtrunk@46ã¸ã®å·®åã§ãããã®å ´ãã®ã対å¿ã§portletãç¡è¦ãã¦ããããã®ã§JIRAã¯è¦éã£ã¦ãã¾ãã
ã¾ãããã ãç´ã£ãã¨ããã§ä»ã«ãã¨ã©ã¼ããã¿ããã§ããâ¦â¦
Index: src/org/seasar/kijimuna/core/ConstCore.java =================================================================== --- src/org/seasar/kijimuna/core/ConstCore.java (revision 46) +++ src/org/seasar/kijimuna/core/ConstCore.java (working copy) @@ -153,6 +153,8 @@ public static final String MODEL_NAME_RESPONSE = "response"; public static final String MODEL_NAME_SESSION = "session"; public static final String MODEL_NAME_SERVLETCONTEXT = "servletContext"; + // S2.4ã·ãªã¼ãº + public static final String MODEL_NAME_APPLICATION = "application"; public static final int RECORDER_EVENT_INIT = 0; public static final int RECORDER_EVENT_RESTORE = 1; Index: src/org/seasar/kijimuna/core/internal/dicon/model/ContainerElement.java =================================================================== --- src/org/seasar/kijimuna/core/internal/dicon/model/ContainerElement.java (revision 46) +++ src/org/seasar/kijimuna/core/internal/dicon/model/ContainerElement.java (working copy) @@ -44,6 +44,7 @@ import org.seasar.kijimuna.core.rtti.IRttiConstructorDesctiptor; import org.seasar.kijimuna.core.rtti.IRttiPropertyDescriptor; import org.seasar.kijimuna.core.util.ProjectUtils; +import org.seasar.kijimuna.core.util.S2VersionUtil; import org.seasar.kijimuna.core.util.StringUtils; /** @@ -68,12 +69,18 @@ IComponentKey interfaceKey = createComponentKey(rtti); componentDefMap.put(interfaceKey, this); containerKeySet.add(interfaceKey); - - addMagicComponent(project, storage, MODEL_NAME_REQUEST, MODEL_INTERFACE_REQUEST); - addMagicComponent(project, storage, MODEL_NAME_RESPONSE, MODEL_INTERFACE_RESPONSE); - addMagicComponent(project, storage, MODEL_NAME_SESSION, MODEL_INTERFACE_SESSION); - addMagicComponent(project, storage, MODEL_NAME_SERVLETCONTEXT, + + setUpMagicComponents(); + } + + private void setUpMagicComponents() { + // TODO: web.xmlãè¦ã¦servletãportletãå¤æããå¿ è¦ãã + addMagicComponent(S2VersionUtil.isUsingVersion4(getProject()) ? + MODEL_NAME_APPLICATION : MODEL_NAME_SERVLETCONTEXT, MODEL_INTERFACE_SERVLETCONTEXT); + addMagicComponent(MODEL_NAME_REQUEST, MODEL_INTERFACE_REQUEST); + addMagicComponent(MODEL_NAME_RESPONSE, MODEL_INTERFACE_RESPONSE); + addMagicComponent(MODEL_NAME_SESSION, MODEL_INTERFACE_SESSION); } private IRtti getS2ContainerRtti() { @@ -83,6 +90,10 @@ return s2ContainerRtti; } + private void addMagicComponent(String name, String clazz) { + addMagicComponent(getProject(), getStorage(), name, clazz); + } + private void addMagicComponent(IProject project, IStorage storage, String name, String clazz) { ComponentElement element = new ComponentElement(project, storage); Index: src/org/seasar/kijimuna/core/util/S2VersionUtil.java =================================================================== --- src/org/seasar/kijimuna/core/util/S2VersionUtil.java (revision 0) +++ src/org/seasar/kijimuna/core/util/S2VersionUtil.java (revision 0) @@ -0,0 +1,52 @@ +/* + * Copyright 2004-2006 the Seasar Foundation and the Others. + * + * Licensed 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.seasar.kijimuna.core.util; + +import org.eclipse.core.resources.IProject; + +import org.seasar.kijimuna.core.dicon.DiconNature; +import org.seasar.kijimuna.core.rtti.HasErrorRtti; +import org.seasar.kijimuna.core.rtti.IRtti; +import org.seasar.kijimuna.core.rtti.RttiLoader; + +public class S2VersionUtil { + + private static final String VERSION_3 = + "org.seasar.framework.util.EclipseUtil"; + + private static final String VERSION_4 = + "org.seasar.framework.container.ExternalContext"; + + public static boolean isUsingVersion3(IProject project) { + return canLoadRtti(project, VERSION_3); + } + + public static boolean isUsingVersion4(IProject project) { + return canLoadRtti(project, VERSION_4); + } + + private static boolean canLoadRtti(IProject project, String fqcn) { + RttiLoader loader = getRttiLoader(project); + IRtti rtti = loader != null ? loader.loadRtti(fqcn) : null; + return rtti != null && !(rtti instanceof HasErrorRtti); + } + + private static RttiLoader getRttiLoader(IProject project) { + DiconNature nature = DiconNature.getInstance(project); + return nature != null ? nature.getRttiLoader() : null; + } + +}