Add some sub-packages
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.guice;
|
||||
package org.springframework.guice.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
@@ -11,7 +11,7 @@
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.guice;
|
||||
package org.springframework.guice.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
@@ -21,6 +21,8 @@ import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan.Filter;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.guice.module.GuiceModuleMetadata;
|
||||
import org.springframework.guice.module.SpringModule;
|
||||
|
||||
/**
|
||||
* Annotation that decorates the whole application context and provides metadata to Guice
|
||||
@@ -28,7 +30,6 @@ import org.springframework.context.annotation.Import;
|
||||
* class (and if added to many then the filters are combined with logical OR). By default
|
||||
* all beans in the context will be bound to Guice with all of their implemented
|
||||
* interfaces. If you need to filter out which beans are added you can filter by class.
|
||||
* TODO: filter by name.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.guice;
|
||||
package org.springframework.guice.annotation;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.ArrayList;
|
||||
@@ -42,6 +42,7 @@ import org.springframework.core.type.filter.AspectJTypeFilter;
|
||||
import org.springframework.core.type.filter.AssignableTypeFilter;
|
||||
import org.springframework.core.type.filter.RegexPatternTypeFilter;
|
||||
import org.springframework.core.type.filter.TypeFilter;
|
||||
import org.springframework.guice.module.GuiceModuleMetadata;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -11,7 +11,7 @@
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.guice;
|
||||
package org.springframework.guice.annotation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -29,6 +29,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.guice.module.SpringModule;
|
||||
|
||||
import com.google.inject.Binding;
|
||||
import com.google.inject.Guice;
|
||||
@@ -11,7 +11,7 @@
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.guice;
|
||||
package org.springframework.guice.injector;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.List;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.guice;
|
||||
package org.springframework.guice.module;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.guice;
|
||||
package org.springframework.guice.module;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Modifier;
|
||||
@@ -28,12 +28,13 @@ import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
|
||||
import org.springframework.core.type.classreading.MetadataReader;
|
||||
import org.springframework.core.type.classreading.MetadataReaderFactory;
|
||||
import org.springframework.core.type.filter.TypeFilter;
|
||||
import org.springframework.guice.annotation.GuiceModule;
|
||||
import org.springframework.util.PatternMatchUtils;
|
||||
|
||||
/**
|
||||
* Encapsulates some metadata about a Guice module that is to be created from the parent context of a <code>@Bean</code>
|
||||
* of this type. Can be used directly as a <code>@Bean</code>, but it is easier to just add <code>@</code>
|
||||
* {@link GuiceModule} to your <code>@Configuration</code>.
|
||||
* Encapsulates some metadata about a Guice module that is to be created from a Spring
|
||||
* application context. Can be used directly as a <code>@Bean</code>, but it is easier to
|
||||
* just add <code>@</code> {@link GuiceModule} to your <code>@Configuration</code>.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*
|
||||
@@ -114,12 +115,12 @@ public class GuiceModuleMetadata implements BindingTypeMatcher {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (includeNames != null && includeNames.length>0) {
|
||||
if (includeNames != null && includeNames.length > 0) {
|
||||
if (!PatternMatchUtils.simpleMatch(includeNames, name)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (excludeNames != null && excludeNames.length>0) {
|
||||
if (excludeNames != null && excludeNames.length > 0) {
|
||||
if (PatternMatchUtils.simpleMatch(excludeNames, name)) {
|
||||
return false;
|
||||
}
|
||||
@@ -138,28 +139,30 @@ public class GuiceModuleMetadata implements BindingTypeMatcher {
|
||||
|
||||
if (includeFilters != null) {
|
||||
try {
|
||||
MetadataReader reader = metadataReaderFactory.getMetadataReader(type.getName());
|
||||
MetadataReader reader = metadataReaderFactory.getMetadataReader(type
|
||||
.getName());
|
||||
for (TypeFilter filter : includeFilters) {
|
||||
if (!filter.match(reader, metadataReaderFactory)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new IllegalStateException("Cannot read metadata for class " + type, e);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException("Cannot read metadata for class " + type,
|
||||
e);
|
||||
}
|
||||
}
|
||||
if (excludeFilters != null) {
|
||||
try {
|
||||
MetadataReader reader = metadataReaderFactory.getMetadataReader(type.getName());
|
||||
MetadataReader reader = metadataReaderFactory.getMetadataReader(type
|
||||
.getName());
|
||||
for (TypeFilter filter : excludeFilters) {
|
||||
if (filter.match(reader, metadataReaderFactory)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new IllegalStateException("Cannot read metadata for class " + type, e);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException("Cannot read metadata for class " + type,
|
||||
e);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -168,7 +171,8 @@ public class GuiceModuleMetadata implements BindingTypeMatcher {
|
||||
private boolean visible(Class<?> type) {
|
||||
Class<?> cls = type;
|
||||
while (cls != null && cls != Object.class) {
|
||||
if (!Modifier.isInterface(cls.getModifiers()) && !Modifier.isPublic(cls.getModifiers())
|
||||
if (!Modifier.isInterface(cls.getModifiers())
|
||||
&& !Modifier.isPublic(cls.getModifiers())
|
||||
&& !Modifier.isProtected(cls.getModifiers())) {
|
||||
return false;
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.guice;
|
||||
package org.springframework.guice.module;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@@ -62,10 +62,10 @@ public abstract class AbstractCompleteWiringTests {
|
||||
assertNotNull(injector.getProvider(Service.class).get());
|
||||
}
|
||||
|
||||
interface Service {
|
||||
public interface Service {
|
||||
}
|
||||
|
||||
protected static class MyService implements Service {
|
||||
public static class MyService implements Service {
|
||||
}
|
||||
|
||||
public static class Foo {
|
||||
|
||||
@@ -7,6 +7,8 @@ import javax.inject.Inject;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.guice.annotation.ModuleRegistryConfiguration;
|
||||
import org.springframework.guice.injector.SpringInjector;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.guice;
|
||||
package org.springframework.guice.annotation;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
@@ -24,6 +24,8 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.FilterType;
|
||||
import org.springframework.context.annotation.ComponentScan.Filter;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.guice.annotation.EnableGuiceModules;
|
||||
import org.springframework.guice.annotation.GuiceModule;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.guice;
|
||||
package org.springframework.guice.annotation;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
@@ -25,6 +25,8 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan.Filter;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.FilterType;
|
||||
import org.springframework.guice.annotation.GuiceModule;
|
||||
import org.springframework.guice.module.SpringModule;
|
||||
|
||||
import com.google.inject.ConfigurationException;
|
||||
import com.google.inject.Guice;
|
||||
@@ -11,7 +11,7 @@
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.guice;
|
||||
package org.springframework.guice.annotation;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
@@ -19,6 +19,8 @@ import org.junit.Test;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.guice.AbstractCompleteWiringTests;
|
||||
import org.springframework.guice.injector.SpringInjector;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Injector;
|
||||
@@ -11,11 +11,12 @@
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.guice;
|
||||
package org.springframework.guice.injector;
|
||||
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.guice.AbstractCompleteWiringTests;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.guice;
|
||||
package org.springframework.guice.module;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
@@ -28,6 +28,8 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.core.type.filter.AnnotationTypeFilter;
|
||||
import org.springframework.core.type.filter.AssignableTypeFilter;
|
||||
import org.springframework.guice.module.GuiceModuleMetadata;
|
||||
import org.springframework.guice.module.SpringModule;
|
||||
|
||||
import com.google.inject.ConfigurationException;
|
||||
import com.google.inject.Guice;
|
||||
@@ -11,13 +11,14 @@
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.guice;
|
||||
package org.springframework.guice.module;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.guice.AbstractCompleteWiringTests;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
Reference in New Issue
Block a user